docs: clarify async onResponse usage#478
Open
barry166 wants to merge 1 commit into
Open
Conversation
The runtime already allows an async onResponse callback to wait before sending a replacement body, but the docs and TypeScript hook type only described synchronous callbacks. This records the supported usage with runtime and type coverage instead of changing the proxy path. Constraint: fastify#380 asks about async onResponse usage and maintainers requested PRs with tests Rejected: Change runtime control flow | async callbacks that call reply.send after await already work in the existing callback path Confidence: high Scope-risk: narrow Directive: Keep async callback errors user-handled unless the runtime explicitly adds async error routing Tested: npm run test:unit -- test/onResponse.test.js; npm run test:typescript; npm run lint; git diff --check Not-tested: Full npm test has pre-existing local failures for invalid-target expectations and Unix socket path length on this macOS checkout
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
onResponseusage for reading an upstream response before replying.Promise<void>.onResponsecallbacks.Fixes #380.
Verification
npm run test:unit -- test/onResponse.test.jsnpm run test:typescriptnpm run lintgit diff --checkI also ran
npm test; the touchedonResponseand TypeScript tests passed, but the full local suite has unrelated failures in this checkout:listen EINVALon long local socket paths under this workspaceContribution notes
content-typefast parse #472, feat: HTTP trailers support infrastructure #429); issue/title/core-term PR searches found no open or merged competing PR for asynconResponsedocs/types.