docs: fix code examples that crash at runtime and other inaccuracies#5386
Merged
Conversation
Fixes nodejs#5385 - Dispatcher.md: fix DNS interceptor imports (Client -> Agent), fix retry example heading (Redirect -> Retry) - H2CClient.md: add async to .then() callback to fix await SyntaxError - EnvHttpProxyAgent.md: fix destructuring json from Response (use response.json()) - Cookies.md: fix sameSite type (String -> Strict) - RetryHandler.md: fix retry callback return type (number|null -> void) - Fetch.md: fix heading (Header -> Headers)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5386 +/- ##
=======================================
Coverage 93.25% 93.25%
=======================================
Files 110 110
Lines 36752 36752
=======================================
Hits 34274 34274
Misses 2478 2478 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
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.
Fixes #5385
High severity
Dispatcher.md — DNS interceptor examples missing
AgentimportBoth DNS examples import
Clientbut usenew Agent(). Running these givesReferenceError: Agent is not defined. Changed import toAgent.H2CClient.md —
awaitin non-async.then()callbackThe example uses
awaitinside.then(() => {which is aSyntaxError. Addedasyncto the callback.EnvHttpProxyAgent.md — Destructuring
jsonfrom ResponseTwo examples destructure
jsonfrom a fetch Response (const { status, json } = await fetch(...)), butjsonis a prototype method — destructuring yieldsundefinedandawait json()throwsTypeError. Changed to useresponse.json().Medium severity
Dispatcher.md — Retry example heading says "Redirect" (copy-paste)
Changed to "Basic Retry Interceptor".
Cookies.md —
sameSitetype says"String"not"Strict"RetryHandler.md —
retrycallback return type wrongChanged
number | nulltovoidto match implementation and RetryAgent.md.Low severity
Fetch.md — Heading says
HeadernotHeadersAll changes verified against the actual source code.