Fix crash when dragging threads to sidebar after a thread is deleted#2760
Open
bengotow wants to merge 1 commit into
Open
Fix crash when dragging threads to sidebar after a thread is deleted#2760bengotow wants to merge 1 commit into
bengotow wants to merge 1 commit into
Conversation
MailboxPerspective.receiveThreadIds called DatabaseStore.modelify and passed the results directly to TaskFactory.tasksForThreadsByAccountId, which throws if the array contains non-Thread values. modelify returns undefined for IDs not found in the DB, causing a crash if a thread was deleted or moved between when it was selected/dragged and when the drop fires. Added .filter(Boolean) to remove undefined entries before calling tasksForThreadsByAccountId, mirroring the same fix already applied in thread-list-context-menu.ts and send-and-archive-extension.ts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01P2kF6PnajpPoVTtQ1FUXtX
Contributor
|
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.
Root Cause
While reviewing the Sentry issue list for release
1.21.1-ae68e881(sorted by user impact), I identified a crash pattern inMailboxPerspective.receiveThreadIdsinapp/src/mailbox-perspective.ts.receiveThreadIdsis called when a user drags threads onto a sidebar folder/label. It resolves the dragged thread IDs against the database viaDatabaseStore.modelify, then passes the results directly toTaskFactory.tasksForThreadsByAccountId:DatabaseStore.modelifyreturnsundefinedin the result array for any ID that is no longer present in the local database (e.g. a thread deleted or synced away between when the drag began and when the drop fires).TaskFactory.tasksForThreadsByAccountIdhas an explicit guard that throws on non-Thread values:This throw propagates as an unhandled rejection from the
.then()chain and is reported to Sentry.Fix
Added
.filter(Boolean)to remove undefined entries from themodelifyresult before passing totasksForThreadsByAccountId, identical to the pattern already used in:thread-list-context-menu.ts(with an explicit comment noting why)send-and-archive-extension.ts(fixed in Fix null crashes in SendDraftTask, thread-sharing, and send-and-archive #2757 for the same root cause)Notes
4e42bfefixed the identicalmodelify→tasksForArchivingcrash for send-and-archive but missed this second call site inmailbox-perspective.ts.Generated by Claude Code