Skip to content

fix: Ignore network failures when cancelling background alerts - #13

Merged
do0ori merged 2 commits into
mainfrom
fix/background-alert-cancel-network-errors
Sep 4, 2026
Merged

fix: Ignore network failures when cancelling background alerts#13
do0ori merged 2 commits into
mainfrom
fix/background-alert-cancel-network-errors

Conversation

@do0ori

@do0ori do0ori commented Sep 4, 2026

Copy link
Copy Markdown
Owner

문제

프로덕션 Sentry에 TypeError: Failed to fetchmechanism: onunhandledrejection으로 올라온다. breadcrumb은 [error] fetch: DELETE https://visual-timer-notifications.do0ori.workers.dev/v1/schedules/default를 가리킨다.

원인

cancelTimerNotificationfetchawait만 하고 예외를 처리하지 않는데, useTimer의 호출 지점 6곳이 전부 void cancelTimerNotification(timer.id) 형태의 fire-and-forget이다. 같은 파일의 scheduleTimerNotificationclearRunningStatus에는 호출부에 .catch()가 붙어 있으나 cancel 경로만 빠져 있었다.

그 결과 오프라인이거나 페이지가 백그라운드로 내려간 상태에서 요청이 실패하면 그대로 unhandled rejection이 된다. 리포트의 breadcrumb에 남은 Document is hidden on mount / handleVisibilityChange가 이 상황과 일치한다. 취소 동작 자체는 로컬에서 이미 끝나 있어 사용자에게 보이는 영향은 없고 Sentry 노이즈만 발생한다.

수정

호출부 6곳에 .catch()를 다는 대신 cancelTimerNotification 자체에서 처리했다. 앞으로 추가될 호출부에서 또 빠뜨릴 여지를 없애기 위해서다.

실패 시 저장된 credentials는 지우지 않고 남긴다. createScheduleCredentials는 저장된 값이 없으면 capability 토큰을 새로 발급하므로, 여기서 지우면 서버에 남아 있는 스케줄을 나중에 삭제할 수단이 사라진다.

검증

먼저 실패하는 테스트로 오류를 재현한 뒤 수정했다.

  • 성공 시 스케줄을 삭제하고 credentials를 정리하는 테스트
  • TypeError: Failed to fetch로 실패할 때 reject하지 않고 credentials를 보존하는 테스트

npm test 32 passed, tsc --noEmitnpm run build 모두 정상.

🤖 Generated with Claude Code

@do0ori
do0ori merged commit c3ee286 into main Sep 4, 2026
1 check passed
@do0ori
do0ori deleted the fix/background-alert-cancel-network-errors branch September 4, 2026 00:27
do0ori added a commit that referenced this pull request Sep 4, 2026
…k-errors

fix: Ignore network failures when cancelling background alerts
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.

1 participant