Skip to content

[๐Ÿ› Bug] oauth ์ธ์ฆ - ์„ธ์…˜ ์ •๋ณด Redis ์ €์žฅ ์•ˆ๋˜๋Š” ๋ฌธ์ œ ์ˆ˜์ • - #15

Merged
juice119 merged 12 commits into
mainfrom
fix/14-auth-redis
Jul 10, 2026
Merged

[๐Ÿ› Bug] oauth ์ธ์ฆ - ์„ธ์…˜ ์ •๋ณด Redis ์ €์žฅ ์•ˆ๋˜๋Š” ๋ฌธ์ œ ์ˆ˜์ •#15
juice119 merged 12 commits into
mainfrom
fix/14-auth-redis

Conversation

@juice119

@juice119 juice119 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

ํ˜„์ƒ

GitHub OAuth ๋กœ๊ทธ์ธ ํ›„ ๋ฆฌ๋‹ค์ด๋ ‰ํŠธ๋Š” ๋˜์ง€๋งŒ Redis์— ์„ธ์…˜ ์ •๋ณด๊ฐ€ ์ €์žฅ๋˜์ง€ ์•Š์Œ

๋ฒ„๊ทธ ์›์ธ

connect-redis๋Š” v9.0.0 ๋ฆด๋ฆฌ์ฆˆ ๋…ธํŠธ์—์„œ ioredis ์ง€์›์„ ๊ณต์‹์ ์œผ๋กœ ์ค‘๋‹จํ–ˆ๋‹ค:

This library no longer supports ioredis. It only supports redis (v5 and later) now.
Rationale: Due to the growing divergence between the ioredis and redis libraries, it was causing this library to maintain shims to synthesize the two, which was a source of issues and overhead.

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 ์กฐํ•ฉ์—์„œ ๊นจ์ ธ์žˆ๋˜ ์ง€์ )
  • Redis ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋‚ด๋ฆฐ ์ƒํƒœ์—์„œ API ๊ธฐ๋™ ์‹œ 5ํšŒ ์žฌ์‹œ๋„ ํ›„ fail-fast๋กœ ์ •์ƒ ์ข…๋ฃŒ๋จ์„ ํ™•์ธ, ์žฌ๊ธฐ๋™ ํ›„ ์ •์ƒ ๋ถ€ํŒ… ํ™•์ธ

๋ฆฌ๋ทฐ์–ด ์ฐธ๊ณ ์‚ฌํ•ญ

  • base ๋ธŒ๋žœ์น˜๋ฅผ main์ด ์•„๋‹Œ feat/12-signout([โœจ Feature] oauth ์ธ์ฆ - ๋กœ๊ทธ์•„์›ƒ ์‹œ accessToken ๋งŒ๋ฃŒ ย #13)์œผ๋กœ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. #13์ด ์•„์ง open ์ƒํƒœ๋ผ diff ๋ฒ”์œ„๋ฅผ ์ขํžˆ๊ธฐ ์œ„ํ•จ์ด๋ฉฐ, #13์ด ๋จธ์ง€๋˜๋ฉด GitHub๊ฐ€ ์ž๋™์œผ๋กœ base๋ฅผ main์œผ๋กœ ์žฌํƒ€๊ฒŸํŒ…ํ•ฉ๋‹ˆ๋‹ค.
  • ์‹ค์ œ GitHub OAuth ๋ธŒ๋ผ์šฐ์ € ๋กœ๊ทธ์ธ ํ๋ฆ„๊นŒ์ง€๋Š” ์ž๋™ ๊ฒ€์ฆํ•˜์ง€ ๋ชปํ•ด, RedisStore ๋™์ž‘์„ ์ง์ ‘ ์Šคํฌ๋ฆฝํŠธ๋กœ ๊ฒ€์ฆํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋Œ€์ฒดํ–ˆ์Šต๋‹ˆ๋‹ค.

@juice119 juice119 self-assigned this Jul 9, 2026
@juice119 juice119 added the ๐Ÿ› bug Something isn't working label Jul 9, 2026
@juice119
juice119 force-pushed the fix/14-auth-redis branch 2 times, most recently from 6edd413 to baa7bba Compare July 9, 2026 06:53
Comment thread backend/libs/common/src/redis/createRedisClient.ts Outdated
Comment thread backend/libs/common/src/redis/createRedisClient.ts Outdated
Comment thread backend/libs/common/src/redis/createRedisClient.ts Outdated
juice119 and others added 9 commits July 10, 2026 09:06
reconnectStrategy ๋ฏธ์„ค์ • ์‹œ Redis ๋‹ค์šด ์ƒํƒœ์—์„œ API ์„œ๋ฒ„๊ฐ€ fail-fast ์—†์ด
๋ฌดํ•œ ์žฌ์‹œ๋„ํ•˜๋ฉฐ ๊ธฐ๋™์ด ์˜์›ํžˆ ๋ฉˆ์ถ”๋Š” ๋ฌธ์ œ๋ฅผ ํ™•์ธํ•ด ์žฌ์‹œ๋„ ํšŸ์ˆ˜๋ฅผ 5ํšŒ๋กœ ์ œํ•œ
- Redis ํด๋ผ์ด์–ธํŠธ ์ƒ์„ฑ ๋กœ์ง์„ createRedisClient๋กœ ์ถ”์ถœํ•ด main.ts์™€ e2e ํ…Œ์ŠคํŠธ๊ฐ€ ๊ณต์œ 
- ๋กœ์ปฌ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ๊ณผ ์ถฉ๋Œํ•˜์ง€ ์•Š๋„๋ก ๋ณ„๋„ ํฌํŠธ(5433/6380)์˜ e2e ์ „์šฉ docker-compose ์ถ”๊ฐ€
- Redis ์—ฐ๊ฒฐ ์‹คํŒจ ์‹œ afterAll์ด ๋ฉˆ์ถ”์ง€ ์•Š๋„๋ก ์—ฐ๊ฒฐ ์„ฑ๊ณต ์—ฌ๋ถ€๋ฅผ ์ถ”์ ํ•ด ์ •๋ฆฌ
@juice119
juice119 force-pushed the fix/14-auth-redis branch from 9dc2fb6 to d93e77f Compare July 10, 2026 00:06

@juice119 juice119 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‚˜๋ฌด๋‹˜ ๋ฆฌ๋ทฐํ•ด์ฃผ์‹  ๋‚ด์šฉ ๋ฐ˜์˜ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฆฌ๋ทฐ ๋ถ€ํƒ ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

Comment thread backend/env/env.exam-local.yml
Comment thread backend/libs/common/e2e-test/redis/createRedisClient.e2e.spec.ts
Comment thread backend/libs/common/src/redis/createRedisClient.ts
Comment thread backend/libs/common/src/redis/createRedisClient.ts
? new SystemException(
`Redis ์—ฐ๊ฒฐ ์ตœ๋Œ€ ์žฌ์‹œ๋„ ํšŸ์ˆ˜ ${maxConnectRetries} ๋ฅผ ์ดˆ๊ณผํ–ˆ์Šต๋‹ˆ๋‹ค`,
)
: Math.min(retries * reconnectStepMs, maxReconnectStepMs),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[trivial] ์ฒซ๋ฒˆ์งธ ์žฌ์‹œ๋„๋Š” 0 ์ด ๋˜์„œ ์ง€์—ฐ ์—†์ด ๋ฐ”๋กœ ์žฌ์‹œ๋„ ํ•˜๋‹ˆ๊นŒ ๋ถˆํ•„์š”ํ•œ ์„ฑ๋Šฅ ๋ถ€ํ•˜๊ฐ€ ์žˆ์ง€ ์•Š์„๊นŒ์š”?

@juice119 juice119 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‚˜๋ฌด๋‹˜์ด ๋ง์”€ํ•˜์‹  ๋‚ด์šฉ ๋ฐ˜์˜ํ–ˆ์Šต๋‹ˆ๋‹ค

host: options.host,
port: options.port,
reconnectStrategy: (retries: number) => {
const retryCount = retries + 1;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋‚˜๋ฌด๋‹˜์ด ๋ง์”€ํ•˜์‹ ๋Œ€๋กœ retries๊ฐ€ 0์œผ๋กœ ๋”œ๋ ˆ์ด ์—†์ด ๋ฐ”๋กœ ์—ฐ๊ฒฐ์„ ์‹œ๋„ํ•ด์„œ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.


if (retryCount > maxConnectRetries) {
return new SystemException(
`Redis ์—ฐ๊ฒฐ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ${maxConnectRetries}ํšŒ ์žฌ์‹œ๋„(์•ฝ ${getElapsedSeconds(connectStartedAt)}์ดˆ ์†Œ์š”) ํ›„ ์—ฐ๊ฒฐ์„ ์ค‘๋‹จํ•ฉ๋‹ˆ๋‹ค`,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์—ฐ๊ฒฐ ์‹คํŒจ์‹œ ์†Œ์š”์‹œ๊ฐ„๋„ ๊ฐ™์ด ๋ณด์ด๊ฒŒ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

@juice119
juice119 deleted the branch main July 10, 2026 07:06
@juice119 juice119 closed this Jul 10, 2026
@juice119 juice119 reopened this Jul 10, 2026
@juice119
juice119 changed the base branch from feat/12-signout to main July 10, 2026 07:11
@sonarqubecloud

Copy link
Copy Markdown

@juice119
juice119 merged commit 59d8472 into main Jul 10, 2026
3 checks passed
@juice119
juice119 deleted the fix/14-auth-redis branch July 31, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

๐Ÿ› bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[๐Ÿ› Bug]oauth ์ธ์ฆ ๊ตฌํ˜„ - ์„ธ์…˜ ์ •๋ณด ์ €์žฅ ์•ˆ๋˜๋Š” ๋ฌธ์ œ

2 participants