fix(blabsy): recover composer when a Blab fails to send#1037
Conversation
📝 WalkthroughWalkthroughThe ChangessendTweet Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
platforms/blabsy/client/src/components/input/input.tsx (1)
106-107: ⚡ Quick winAvoid the extra read: use
tweetRef.iddirectly.At Line 106,
getDoc(tweetRef)is unnecessary for obtaining the ID.addDoc(...)already returns a ref withid, so this adds avoidable network latency.Suggested change
- const { id: tweetId } = await getDoc(tweetRef); + const tweetId = tweetRef.id;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@platforms/blabsy/client/src/components/input/input.tsx` around lines 106 - 107, Remove the unnecessary getDoc() call at line 106 where the tweetId is extracted. Since addDoc() already returns a DocumentReference with an id property, directly access tweetRef.id instead of awaiting getDoc(tweetRef) and destructuring the id from the result. Replace the destructuring assignment with a simple const tweetId = tweetRef.id statement to eliminate the extra network read and reduce latency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@platforms/blabsy/client/src/components/input/input.tsx`:
- Around line 99-104: The Promise.all at lines 99-104 treats addDoc and counter
updates (manageTotalTweets, manageTotalPhotos, manageReply) as equally critical.
When addDoc succeeds but a counter update fails, the entire operation fails in
the catch block at line 129, incorrectly telling the user the Blab failed to
send (causing duplicates on retry). Instead, separate the logic into two phases:
first, await only the addDoc call to confirm the Blab is saved (treat this
success as the canonical send success); then, separately fire off the
manageTotalTweets, manageTotalPhotos, and manageReply updates as best-effort
operations with their own error handling and logging, so their failures don't
block the user-visible send success.
---
Nitpick comments:
In `@platforms/blabsy/client/src/components/input/input.tsx`:
- Around line 106-107: Remove the unnecessary getDoc() call at line 106 where
the tweetId is extracted. Since addDoc() already returns a DocumentReference
with an id property, directly access tweetRef.id instead of awaiting
getDoc(tweetRef) and destructuring the id from the result. Replace the
destructuring assignment with a simple const tweetId = tweetRef.id statement to
eliminate the extra network read and reduce latency.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: ff2aedea-5547-4273-93f6-3f7962f5fe96
📒 Files selected for processing (1)
platforms/blabsy/client/src/components/input/input.tsx
Addresses review feedback: addDoc and the counter updates ran together in Promise.all, so if addDoc succeeded but manageTotalTweets/manageTotalPhotos rejected, the catch reported "Failed to send" even though the Blab was created — prompting a retry and duplicate Blabs while metrics drift. Await addDoc on its own as the canonical send, then run the counter/reply updates best-effort (logged, non-fatal). Also use tweetRef.id directly instead of an extra getDoc round-trip, removing another post-send failure point (and a read). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Description of change
sendTweetin the Blab composer setloading = trueand only cleared it on the success path, with no error handling. When an image upload rejected (e.g. Firebase Storage quota exceeded, or a flaky mobile network), the promise rejected, the loading state was never reset, and the composer froze with no feedback — matching the reported "Blab stuck with 2+ images" behaviour (more images → higher chance one upload fails).This wraps the send flow in
try/catch: on failure it resets the loading state and shows an error toast, so the composer always recovers and the user can retry.Issue Number
closes #1025
Type of change
How the change has been tested
Tested locally against the Firebase emulators (auth/firestore/storage), to work around the exhausted staging quota:
createin the rules to simulate the quota failure; confirmed the composer now shows an error toast ("Failed to send your Blab. Please try again.") and becomes usable again, instead of freezing silently.pnpm exec tsc --noEmitpasses.Change checklist
Summary by CodeRabbit
Bug Fixes