fix(desktop): capture context name before awaits in handleDelete#490
Conversation
The reactive `context` prop is derived from the contexts store. After refreshContexts() removes the deleted context, the derived prop becomes undefined and reading context.name on the success line throws, showing a false "Failed to delete context" toast even though deletion succeeded. Hoist the name into a local before the awaits.
✅ Deploy Preview for devsydev canceled.
|
|
Warning Review limit reached
More reviews will be available in 5 minutes and 8 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
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 |
Summary
Failed to delete context: Cannot read properties of undefined (reading 'name')error when deleting a non-default context.handleDeleteinContextSheet.sveltereadcontext.nameafterawait refreshContexts(). Thecontextprop is reactive — derived inContextsPage.sveltevia$contexts.find(...). Once the deleted context leaves the store, that derived returnsundefined, nulling the prop, so the success linecontext.namethrows. The deletion actually succeeded, so the user saw a false failure toast.const name = context.namebefore the awaits and use it throughout.