Repository navigation
fix(content): keep a webhook's 2xx as sent when the rest of its answer doesn't arrive in time - #1668
Merged
Conversation
…r doesn't arrive in time Follow-up from ansvisor#1605 (item 1). A webhook that sends 200 and part of its answer, then nothing more, was reported as a timeout: the time limit's abort reaches the request's error handler before the answer's, so postJson rejected with `timeout` though the status had arrived. A send was marked failed, and a task send reported as refused. postJson now remembers once the status has arrived; an error the request hears after that (the time limit, the connection dropping) ends that answer with what was read of it. The docs' Delivery line says so. The new test fails on main: a 200 that stalls past a 100 ms limit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
gkhngyk
approved these changes
Oct 28, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good, with follow-ups.
What I checked:
- Merge. One commit (e0f058d) on 3f6a4d4. It merges clean on main (b591947), alone and together with #1672 and #1673. None of the files it touches changed on main since its base.
- The fix.
answeredis set at the end of the response callback, so it's only set once the status has arrived. After that, any request error (the time limit, a reset) resolves withdone(), which keeps the first result and what was read. Before the status arrives, nothing changes: our ownPageFetchErrors,timeoutandunreachableare reported as before. - Callers.
- Send to CMS (
content-delivery.js) and webhook dispatch (webhook-dispatch.js) count only a 2xx as delivered, so a 4xx or 5xx that stalls is now "the webhook answered 503" rather than "took too long". - The webhook test reports the status it got, with
successonly for a 2xx. - The opportunity sends (
/bulk/send-webhookand/:id/send-webhook) only turn away a 3xx; see follow-up 1.
- Send to CMS (
- Tests.
- At the head, the
safe-post,content-webhooks,content-deliveryandwebhook-dispatchtests pass (79). - With main's
safe-post.jsunder the head's tests, the new/stalledtest fails, as described. - CI passes.
- At the head, the
- Docs. The Delivery line matches what
postJsonnow does. - Before the API deploy. This is server only. Nothing changes for anyone until the API is deployed.
- Speed. No regex and no loop over user input.
Follow-ups:
- The description says all callers check for 2xx, but the opportunity sends don't (
server/src/routes/content.js, bulk and singlesend-webhook). They mark any answer except a 3xx assent. Before this PR, a 4xx or 5xx whose answer stalled past 15 s was a timeout, so the opportunity stayed unsent. Now it's markedsent. That's rare and comes from the existing gap #1672 notes. A follow-up that fails a non-2xx there, as Send to CMS does, covers both. Please also fix that sentence in the description.
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.
Summary
Follow-up from #1605 (item 1): a webhook's 2xx counts as sent even when the rest of its answer doesn't arrive in time.
A webhook that sent 200 and part of its answer, then nothing more, was reported as a timeout. The time limit's abort reached the request's error handler before the answer's, so
postJsonrejected withtimeouteven though the status had arrived. A content send was marked failed, and a task send was reported as refused.postJsonnow remembers when the status has arrived. An error the request hears after that (the time limit, or the connection dropping) ends the answer with what was read of it.docs/api-reference/webhooks.mdx: the Delivery line says so.Where people see it: a page sent to a slow webhook stays "sent".
Related issue
Follow-up from #1605's review.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/safe-post.test.js. The new test fails on main: a 200 that stalls past a 100 ms limit.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)Full checks were run once, in one tree with this batch's ten follow-up branches merged:
npm test: 246 files, 3,343 tests passed;vitest: 4,348 of 4,349 tests passed. The editor'spage.test.tsxtimed out under load; it passed alone (271/271).A pre-push review was run on all ten branches.
🤖 Generated with Claude Code