Skip to content

fix: 배포 후 SW 캐시 미정리로 인한 접속 불가 수정#263

Merged
sdk-kr merged 1 commit into
damoang:mainfrom
unstable-code:fix/sw-cache-reload-bug
Mar 6, 2026
Merged

fix: 배포 후 SW 캐시 미정리로 인한 접속 불가 수정#263
sdk-kr merged 1 commit into
damoang:mainfrom
unstable-code:fix/sw-cache-reload-bug

Conversation

@unstable-code
Copy link
Copy Markdown
Collaborator

Summary

  • 배포 후 "새로고침하면 된다" 메시지만 나오고 접속 불가한 문제 수정
  • SW unregister/cache delete Promise를 await하지 않아 캐시 정리 전에 리로드되는 버그

원인

clearCachesAndReload()에서 forEachunregister()caches.delete()를 호출하면서 반환된 Promise를 무시. 캐시 정리가 완료되기 전에 location.replace()가 실행되어 이전 SW가 여전히 stale 캐시를 제공.

변경 내역

  • hooks.client.ts: async/await로 SW 해제 → 캐시 삭제 → 리로드 순차 보장
  • sw.js: SKIP_WAITING 메시지 핸들러 추가 (대기 중인 새 SW 즉시 활성화)

사용자 영향

  • Before: 수동으로 브라우저 캐시 전체 삭제 필요
  • After: 배너의 "새로고침" 버튼 한 번으로 복구

Ref: https://damoang.net/free/5900985

Test plan

  • 배포 후 기존 SW 캐시가 남아있는 상태에서 chunk error 발생 시 자동 복구 확인
  • 배너 새로고침 버튼 클릭 시 정상 로딩 확인
  • 새 SW 대기 중일 때 SKIP_WAITING으로 즉시 활성화 확인

🤖 Generated with Claude Code

배포 후 chunk load error 발생 시 clearCachesAndReload()에서
SW unregister/cache delete의 Promise를 await하지 않아
캐시 정리 완료 전에 리로드가 실행되는 버그 수정.

- hooks.client.ts: async/await로 순차 실행 보장
- sw.js: SKIP_WAITING 메시지 핸들러 추가

사용자가 수동 캐시 삭제 없이 배너 새로고침 버튼으로 복구 가능.

Ref: https://damoang.net/free/5900985

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@sdk-kr sdk-kr left a comment

Choose a reason for hiding this comment

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

LGTM 감사합니다.

@sdk-kr sdk-kr marked this pull request as ready for review March 6, 2026 08:23
@sdk-kr sdk-kr merged commit ed96314 into damoang:main Mar 6, 2026
8 of 12 checks passed
@unstable-code unstable-code deleted the fix/sw-cache-reload-bug branch March 6, 2026 08:37
sdk-kr pushed a commit that referenced this pull request Mar 6, 2026
## Summary
- #263 (`ed96314`) 커밋 revert
- 해당 변경으로 인해 무한 새로고침이 발생하는 문제 확인

## Reverted commit
- `ed96314` fix: 배포 후 SW 캐시 미정리로 인한 접속 불가 수정 (#263)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
sdk-kr pushed a commit that referenced this pull request Mar 7, 2026
## Summary
- 배포 후 "새로고침하면 된다" 메시지만 나오고 접속 불가한 문제 수정
- SW unregister/cache delete Promise를 await하지 않아 캐시 정리 전에 리로드되는 버그

## 원인
`clearCachesAndReload()`에서 `forEach`로 `unregister()`와 `caches.delete()`를
호출하면서 반환된 Promise를 무시. 캐시 정리가 완료되기 전에 `location.replace()`가 실행되어 이전 SW가
여전히 stale 캐시를 제공.

## 변경 내역
- `hooks.client.ts`: `async/await`로 SW 해제 → 캐시 삭제 → 리로드 순차 보장
- `sw.js`: `SKIP_WAITING` 메시지 핸들러 추가 (대기 중인 새 SW 즉시 활성화)

## 사용자 영향
- Before: 수동으로 브라우저 캐시 전체 삭제 필요
- After: 배너의 "새로고침" 버튼 한 번으로 복구

Ref: https://damoang.net/free/5900985

## Test plan
- [ ] 배포 후 기존 SW 캐시가 남아있는 상태에서 chunk error 발생 시 자동 복구 확인
- [ ] 배너 새로고침 버튼 클릭 시 정상 로딩 확인
- [ ] 새 SW 대기 중일 때 SKIP_WAITING으로 즉시 활성화 확인

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
sdk-kr pushed a commit that referenced this pull request Mar 7, 2026
## Summary
- #263 (`c6ed450`) 커밋 revert
- 해당 변경으로 인해 무한 새로고침이 발생하는 문제 확인

## Reverted commit
- `c6ed450` fix: 배포 후 SW 캐시 미정리로 인한 접속 불가 수정 (#263)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants