Answering a decision from the composer throws unhandled on a dead link, instead of failing like every other send
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 88/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
Start in src/client/components/App.tsx:266-286 and compare the composer decision-answer path with the existing guarded send paths at lines 317-329 and in DecisionSheet.tsx:201-217. Run pnpm test -- composer, then add or update a regression test using answerFails: "reject" for the composer path. Done means the rejection shows the normal error, resets sending state, and produces no unhandled rejection.
Written by the indexing model from the issue text.
Description
What's wrong
App.tsx's submit() has two send paths. The plain-message path (src/client/components/App.tsx:317-329, the giveUp flow) wraps its postJson in a try/catch so a rejected fetch (a dead link, not just a bad status) fails visibly - text restored, an error shown. DecisionSheet.tsx's own send() (src/client/components/DecisionSheet.tsx:201-217) does the same with its own try/catch.
The composer's other send path - answering a decision without opening the sheet, App.tsx:266-286 - has no try/catch around its postJson call:
if (decision && !intake) {
if (!choice && said === "" && attachments.length === 0) return;
setSendState("sending");
tap();
const res = await postJson(`/api/sessions/${row.id}/answer`, { optionId: choice, text: said, images: attachments });
if (!res.ok) { ... }
...
}
If postJson rejects (network down, dead link - fetches.tsx's test helpers call this "reject", as opposed to a bad HTTP status) rather than resolving with a bad status, this throws inside an async function called as void submit() from onSubmit (App.tsx:522), which becomes an unhandled promise rejection. The send state is left stuck on "sending" forever, no error is shown, and nothing is restored - the exact bug #60 and #86 both fixed for the other two send paths.
Found while writing tests/composer-haptics.test.tsx for #95: a test using answerFails: "reject" against this path produced Vitest caught 1 unhandled error during the test run instead of exercising the failure branch. The test was changed to use a bad status (answerFails: 502) instead, which does exercise !res.ok correctly - but the reject path itself is still unhandled in the real app.
Acceptance criteria
- Answering a decision from the composer (not the sheet) with a rejected fetch fails the same visible way a bad status does:
setError,failSend(), no unhandled rejection. -
sendStatedoes not get stuck on"sending"when this happens. - A regression test using
answerFails: "reject"against this exact path (composer, not sheet) passes without an unhandled rejection.
Out of scope
DecisionSheet.tsx's ownsend()- already has atry/catch, not touched by this.- The plain-message path - already has a
try/catch(giveUp), not touched by this.
Verification
pnpm test -- composer
Plus a new test exercising answerFails: "reject" against the composer's decision-answer path specifically.
Related
Found during #95. Same shape of bug as #60 (the sheet) and #86 (the plain-message path), both already fixed - this is the one path that was missed.
- Dominant language
- TypeScript
- Stars
- 2
- Forks
- 0
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 46
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jobizzness/bench
-
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
jobizzness/bench#144 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
jobizzness/bench#124 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
jobizzness/bench#77 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
jobizzness/bench#72 ·
-
Difficulty 2/5 Half a day Newbie friendliness 88/100
jobizzness/bench#39 · 1 comment ·
All issues in jobizzness/bench
Similar issues
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100