fix: honor Resend error envelope and abort refresh on logout - #80
Merged
Conversation
Two real defects surfaced by a senior-dev pass over the codebase:
api/notifications: notifyNewTicket only caught thrown errors from
Resend's `emails.send`, but Resend resolves with `{ data: null, error }`
on delivery rejections (unverified sender, blocked recipient, ...).
Those failures were silently treated as success — the widget POST
returned 201, no email was sent, and no log told the operator why.
sendTestEmail already mirrors the envelope check, so this aligns the
fire-and-forget notification path with the operator-driven probe.
dashboard/AuthContext: logout did not abort the in-flight /me +
/projects refresh. A response that landed during the logout round-trip
could resolve after the state flip and re-mark the user authenticated,
bouncing them back to the inbox instead of the login page. Cancel the
controller before the state flip so any late refresh is a no-op.
https://claude.ai/code/session_01BJZtxNxxeWYbJcUhUdjwX5
Wifsimster
marked this pull request as ready for review
June 3, 2026 17:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two real defects surfaced by a senior-dev pass over the codebase.
1.
api/notifications: silent Resend delivery rejections (HIGH)notifyNewTicketonly caught thrown errors from Resend'semails.send, but Resend resolves with{ data: null, error }on delivery rejections (unverified sender, blocked recipient, suppressed address, etc.). Those failures were silently treated as success — the widget POST returned 201, no email was sent, and no log told the operator why the inbox was empty.sendTestEmailalready mirrors the envelope check, so this aligns the fire-and-forget notification path with the operator-driven probe. Same swallow-and-log posture: returnsfalseinstead oftrue, logs the error object.Added a test (
'returns false and logs when Resend resolves with an error envelope') that pins the new behavior — fake Resend returns{ data: null, error: { message: 'Domain is not verified' } }, andnotifyNewTicketis expected to resolvefalse.2.
dashboard/AuthContext: logout race re-authenticates the user (MEDIUM)logout()did not abort the in-flight/me + /projectsrefresh controller. The race:refresh()is in flight (e.g. mount probe, or background re-fetch).api.logout()runs and resolves.setState({ status: 'unauthenticated' })flips the UI.{ status: 'authenticated', ... }on top.Net effect: the dashboard bounces back to the inbox right after logout. The fix aborts the controller before the state flip so any late refresh response is dropped.
Test plan
pnpm typecheck— clean across all packagespnpm test— 90/90 pass (1 new test innotifications.test.ts)pnpm turbo run build— all packages build[koe/api] notifyNewTicket rejected by Resendinstead of going silentGenerated by Claude Code