[๐ Bug] oauth ์ธ์ฆ - ์ธ์ ์ ๋ณด Redis ์ ์ฅ ์๋๋ ๋ฌธ์ ์์ - #15
Conversation
6edd413 to
baa7bba
Compare
reconnectStrategy ๋ฏธ์ค์ ์ Redis ๋ค์ด ์ํ์์ API ์๋ฒ๊ฐ fail-fast ์์ด ๋ฌดํ ์ฌ์๋ํ๋ฉฐ ๊ธฐ๋์ด ์์ํ ๋ฉ์ถ๋ ๋ฌธ์ ๋ฅผ ํ์ธํด ์ฌ์๋ ํ์๋ฅผ 5ํ๋ก ์ ํ
- Redis ํด๋ผ์ด์ธํธ ์์ฑ ๋ก์ง์ createRedisClient๋ก ์ถ์ถํด main.ts์ e2e ํ ์คํธ๊ฐ ๊ณต์ - ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ๊ณผ ์ถฉ๋ํ์ง ์๋๋ก ๋ณ๋ ํฌํธ(5433/6380)์ e2e ์ ์ฉ docker-compose ์ถ๊ฐ - Redis ์ฐ๊ฒฐ ์คํจ ์ afterAll์ด ๋ฉ์ถ์ง ์๋๋ก ์ฐ๊ฒฐ ์ฑ๊ณต ์ฌ๋ถ๋ฅผ ์ถ์ ํด ์ ๋ฆฌ
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
9dc2fb6 to
d93e77f
Compare
juice119
left a comment
There was a problem hiding this comment.
๋๋ฌด๋ ๋ฆฌ๋ทฐํด์ฃผ์ ๋ด์ฉ ๋ฐ์ํ์ต๋๋ค. ๋ฆฌ๋ทฐ ๋ถํ ๋๋ฆฝ๋๋ค.
| ? new SystemException( | ||
| `Redis ์ฐ๊ฒฐ ์ต๋ ์ฌ์๋ ํ์ ${maxConnectRetries} ๋ฅผ ์ด๊ณผํ์ต๋๋ค`, | ||
| ) | ||
| : Math.min(retries * reconnectStepMs, maxReconnectStepMs), |
There was a problem hiding this comment.
[trivial] ์ฒซ๋ฒ์งธ ์ฌ์๋๋ 0 ์ด ๋์ ์ง์ฐ ์์ด ๋ฐ๋ก ์ฌ์๋ ํ๋๊น ๋ถํ์ํ ์ฑ๋ฅ ๋ถํ๊ฐ ์์ง ์์๊น์?
juice119
left a comment
There was a problem hiding this comment.
๋๋ฌด๋์ด ๋ง์ํ์ ๋ด์ฉ ๋ฐ์ํ์ต๋๋ค
| host: options.host, | ||
| port: options.port, | ||
| reconnectStrategy: (retries: number) => { | ||
| const retryCount = retries + 1; |
There was a problem hiding this comment.
๋๋ฌด๋์ด ๋ง์ํ์ ๋๋ก retries๊ฐ 0์ผ๋ก ๋๋ ์ด ์์ด ๋ฐ๋ก ์ฐ๊ฒฐ์ ์๋ํด์ ์์ ํ์ต๋๋ค.
|
|
||
| if (retryCount > maxConnectRetries) { | ||
| return new SystemException( | ||
| `Redis ์ฐ๊ฒฐ์ ์คํจํ์ต๋๋ค. ${maxConnectRetries}ํ ์ฌ์๋(์ฝ ${getElapsedSeconds(connectStartedAt)}์ด ์์) ํ ์ฐ๊ฒฐ์ ์ค๋จํฉ๋๋ค`, |
There was a problem hiding this comment.
์ฐ๊ฒฐ ์คํจ์ ์์์๊ฐ๋ ๊ฐ์ด ๋ณด์ด๊ฒ ์์ ํ์ต๋๋ค.
|



ํ์
GitHub OAuth ๋ก๊ทธ์ธ ํ ๋ฆฌ๋ค์ด๋ ํธ๋ ๋์ง๋ง Redis์ ์ธ์ ์ ๋ณด๊ฐ ์ ์ฅ๋์ง ์์
๋ฒ๊ทธ ์์ธ
connect-redis๋ v9.0.0 ๋ฆด๋ฆฌ์ฆ ๋ ธํธ์์ ioredis ์ง์์ ๊ณต์์ ์ผ๋ก ์ค๋จํ๋ค:8.x๊น์ง๋
peerDependencies์ redis ํด๋ผ์ด์ธํธ๊ฐ ๋ช ์๋์ง ์์์ง๋ง(๋์จํ ๋์), 9.0.0๋ถํฐredis: ">=5"๊ฐ ๋ช ์์ peerDependency๋ก ์ถ๊ฐ๋๋ค(npm ํ์ธ). ์ด ํ๋ก์ ํธ๋connect-redis@^9.0.0์ ์ฐ๋ฉด์๋ ํด๋ผ์ด์ธํธ๋ ์ฌ์ ํioredis๋ก ์์ฑํ๊ณ ์์๋ ๊ฒ์ด ๊ทผ๋ณธ ์์ธ์ด๋ค.RedisStore๋ด๋ถ ๊ตฌํ๋ node-redis ์ ์ฉ API๋ฅผ ํธ์ถํ๊ณ ์์ด ioredis์ ํธํ๋์ง ์๋๋ค.client.set(key, val, { expiration: { type: 'EX', value: ttl } })โ node-redis ์ต์ ๊ฐ์ฒด ํํ (ioredis๋set(key, val, 'EX', ttl)๊ฐ์ ์์น ์ธ์๋ฅผ ๊ธฐ๋)client.scanIterator({ MATCH, COUNT })โ node-redis ์ ์ฉ ๋ฉ์๋๋ก, ioredis ์ธ์คํด์ค์๋ ์กด์ฌํ์ง ์์ ํธ์ถ ์ ์ฆ์ ์ค๋ฅ์ฆ ์ธ์ ์ ์ฅ(
set)์ TTL ๋ถ๊ธฐ์ ์กฐํ ๊ณ์ด ๋ฉ์๋๊ฐ ๋ฐํ์์ ์ ์ ๋์ํ์ง ์์๋ ๊ฒ์ด ์ด๋ฒ ๋ฒ๊ทธ์ ์์ธ์ด๋ค.์ฐ๊ด ์ด์
Closes #14
์์ ๋ด์ฉ
ioredis์ ๊ฑฐ,redis(node-redis) ํจํค์ง๋ก ๊ต์ฒดmain.ts:createClient+await connect()๋ก ๋น๋๊ธฐ ์ฐ๊ฒฐ ๊ตฌ์กฐ ๋ณ๊ฒฝ, Redis ๋ค์ด ์ ๋ฌดํ ๋๊ธฐํ์ง ์๋๋กreconnectStrategy๋ก ์ฌ์๋ 5ํ ์ ํ ํ fail-fast ์ข ๋ฃsetWebBootstrap.ts:redisClientํ๋ผ๋ฏธํฐ ํ์ ์RedisClientType(redis)์ผ๋ก ๊ต์ฒดํ ์คํธ ๊ฒฐ๊ณผ
pnpm build,pnpm test,pnpm test:e2eํต๊ณผRedisStore์set/get/touch/length/destroy๋ฅผ ์คํฌ๋ฆฝํธ๋ก ์ง์ ํธ์ถํด ์ค์ Redis์ ๋ํด ๊ฒ์ฆ โ TTL์ด ์ ์์ ์ผ๋ก ์ธํ ยท๊ฐฑ์ ๋จ์ ํ์ธ (๊ธฐ์กด ioredis ์กฐํฉ์์ ๊นจ์ ธ์๋ ์ง์ )๋ฆฌ๋ทฐ์ด ์ฐธ๊ณ ์ฌํญ
main์ด ์๋feat/12-signout([โจ Feature] oauth ์ธ์ฆ - ๋ก๊ทธ์์ ์ accessToken ๋ง๋ฃ ย #13)์ผ๋ก ์ค์ ํ์ต๋๋ค. #13์ด ์์ง open ์ํ๋ผ diff ๋ฒ์๋ฅผ ์ขํ๊ธฐ ์ํจ์ด๋ฉฐ, #13์ด ๋จธ์ง๋๋ฉด GitHub๊ฐ ์๋์ผ๋ก base๋ฅผmain์ผ๋ก ์ฌํ๊ฒํ ํฉ๋๋ค.RedisStore๋์์ ์ง์ ์คํฌ๋ฆฝํธ๋ก ๊ฒ์ฆํ๋ ๋ฐฉ์์ผ๋ก ๋์ฒดํ์ต๋๋ค.