fix: unhandled promise rejection when pinning a message fails#41576
fix: unhandled promise rejection when pinning a message fails#41576priyadarshi7 wants to merge 1 commit into
Conversation
`usePinMessageAction` destructured `mutateAsync` from `usePinMessageMutation` but never awaited the returned promise. Unlike `mutate`, `mutateAsync` rejects when the request fails, so a failed pin surfaced as an "Uncaught (in promise)" error even though the failure was already handled. The mutation owns the full lifecycle through its callbacks: `onMutate` applies the optimistic pin, `onError` rolls it back and dispatches the error toast, and `onSettled` invalidates the pinned messages query. The promise result is therefore unused. Switch to `mutate`, which returns `void` and accepts the same arguments, so behaviour is unchanged and the hook now matches its sibling `useUnpinMessageAction`, which already uses `mutate`.
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
🦋 Changeset detectedLatest commit: 34c1e54 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📜 Recent review details⏰ Context from checks skipped due to timeout. (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (3)📚 Learning: 2026-03-16T21:50:37.589ZApplied to files:
📚 Learning: 2026-03-27T14:52:56.865ZApplied to files:
📚 Learning: 2026-05-06T12:21:44.083ZApplied to files:
🔇 Additional comments (2)
WalkthroughThe pin message action now invokes the mutation without awaiting its result, preventing rejected pin operations from producing unhandled promise rejections. A patch changeset documents the fix for ChangesPin message rejection handling
Estimated code review effort: 2 (Simple) | ~5 minutes Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
usePinMessageActiondestructuredmutateAsyncfromusePinMessageMutationbut never awaited the returned promise. Unlikemutate,mutateAsyncrejects when the request fails, so a failed pin surfaced as an "Uncaught (in promise)" error even though the failure was already handled.The mutation owns the full lifecycle through its callbacks:
onMutateapplies the optimistic pin,onErrorrolls it back and dispatches the error toast, andonSettledinvalidates the pinned messages query. The promise result is therefore unused.Switch to
mutate, which returnsvoidand accepts the same arguments, so behaviour is unchanged and the hook now matches its siblinguseUnpinMessageAction, which already usesmutate.Proposed changes (including videos or screenshots)
Issue(s)
Steps to test or reproduce
Further comments
Summary by CodeRabbit