npm / got
got
What changed in got 7 to 16, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
119 breaking2 security43 new APIs and options2 performance38 behavior and defaults1 tooling99 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initgot 1666 changes
Breaking changes 22
Default body, json, and form payloads are no longer sent with every request; payloads are never merged with defaults.
A handlers entry that is not a function now throws an error.
A HEAD request remains HEAD after a 301, 302, or 303 redirect instead of becoming GET.
Negative or fractional values now throw an error.
An empty method now throws an error instead of being accepted.
A prefix URL containing a query string or fragment now throws an error.
The promise response event now fires only for the final response, not for each retry attempt.
Response bodies no longer retain a leading UTF-8 byte order mark.
Negative or fractional retry limits now throw an error.
Hop-by-hop headers are no longer copied to a piped ServerResponse.
agent.http2 is now an opt-out flag; set it to false to skip session pooling. Passing an agent instance throws.
The deprecated auth option stub was removed; passing it now throws Unexpected option.
Piped headers no longer copy credentials, including authorization, cookie, cookie2, set-cookie, and set-cookie2; pass credentials explicitly when the upstream is trusted.
When a hook, retry, or pagination step changes origin, Got strips credentials and clears an unchanged body; set headers or body explicitly to retain them.
The deprecated followRedirects option stub was removed; passing it now throws Unexpected option.
HTTP/2 proxy support is no longer provided by Got; the notes say to keep using http2-wrapper through the request option if needed.
Got now has a built-in HTTP/2 client with session pooling and multiplexing, and no longer relies on http2-wrapper.
The OptionsOfUnknownResponseBody type was removed; it was an alias for StrictOptions.
Use response.statusCode for the status because HTTP/2 response headers no longer contain pseudo-headers.
A server response with Retry-After: 0 now retries immediately instead of using the backoff delay.
The deprecated searchParameters option stub was removed; passing it now throws Unexpected option.
timeout.socket now applies during HTTP/2 TLS negotiation and session setup, reports a socket timeout, and no longer counts DNS lookup time.
New APIs and options 5
The DnsCacheLookup type is now exported.
The DnsCacheOptions type is now exported.
The Timings type is now exported.
Adds got.query() for the QUERY method, which is safe and idempotent, retried by default, and keeps replayable bodies across redirects; the built-in cache does not store QUERY responses.
Adds got.stream.query() for the QUERY method, which is safe and idempotent, retried by default, and keeps replayable bodies across redirects; the built-in cache does not store QUERY responses.
Behavior and default changes 10
The .json() API now supports Standard Schema.
The followRedirect option is evaluated once per response.
Headers now accept number values.
Extending an instance now inherits the parent's mutableDefaults setting, like got.extend(instance).
Stacked content codings are now supported.
The x-gzip content coding is now supported.
With http2: true, a custom HTTPS agent makes Got use the native HTTP/1.1 path because the built-in session pool does not support custom HTTPS agents.
dnsCache: true uses Got's built-in cache; the option also accepts objects with lookup and optional clear functions. The cache resolves A and AAAA records separately and cannot preserve OS-specific verbatim ordering.
URL credentials are preserved when prefixUrl changes to a same-origin value, and credentials in prefixUrl are treated as explicit.
If options.request returns a request or response, it controls the transport and bypasses Got's HTTP/2 client; return undefined to use Got's transport.
Fixes and other changes 29
Hook edge cases are fixed.
Streams configured with a body, json, or form option now reject writes, matching documented behavior.
Content-Length remains correct when a hook replaces the body during a redirect.
Cookie edge cases with retries, redirects, and async cookie jars are fixed.
Upload handling now respects DataView byte ranges.
Diagnostics channel coverage now includes retries and terminal errors.
Custom DNS cache lookups and DNS records without a valid TTL are fixed.
FormData request bodies are retried by re-serializing them instead of failing.
HTTP/2 edge cases are fixed, including requests that could hang forever when a response or request was destroyed.
Infinity timeouts no longer fire immediately or throw.
JSON containing a byte order mark now parses.
Default pagination now handles real-world Link headers, with pagination option and limit edge cases also fixed.
Redirects now keep the URL fragment.
Retries with replaced or non-replayable bodies are fixed.
Error stacks now report the real error class instead of RequestError; other error cause edge cases are fixed.
Response body decoding and parsing edge cases are fixed.
Retry delay edge cases are fixed, including invalid Retry-After values and calculateDelay for afterResponse retries.
Stream handling now respects backpressure.
The request timeout no longer restarts on each redirect; timeout phase edge cases are also fixed.
TypeScript types now match runtime values.
Streams stop forwarding after unpipe.
Upload progress total is fixed for Content-Length: 0.
Web ReadableStream request bodies can now be cancelled correctly.
allowGetBody now works over HTTP/2.
Got waits for asynchronous cookie jar writes on terminal redirect responses, including when followRedirect is false.
When a cookie jar write throws, error.response.body is complete, decompressed, and decoded with the configured encoding; decoding failures no longer mask the original error.
got.stream no longer finalizes the response before the response event or before piped server response headers are set.
Connection errors reported by request.end() are retried instead of failing the request.
strictContentLength no longer counts bytes from responses that were not actually decompressed.
got 1522 changes
Breaking changes 10
Got returns 300 and 304 responses as-is instead of auto-following them; handle them manually if needed.
Automatic copying of headers from piped streams is disabled by default; enable this option to restore it. Hop-by-hop headers are never copied.
Use the native Web API FormData global directly instead of form-data packages.
The undocumented named export for Got is removed; Got has always been a default export.
The isStream option is removed; use got.stream() directly.
Node.js 22 is now required to run Got.
The promise cancel API is removed; use the signal option with AbortController instead.
Buffer responses now return Uint8Array; response.rawBody and promise.buffer() also return Uint8Array, so strict Buffer type checks may need updating.
strictContentLength defaults to true, causing a ContentLengthMismatchError when Content-Length does not match the actual body size; set it to false to restore the old behavior.
The url property is no longer present on options objects passed to hooks; use response.url or request.requestUrl instead.
New APIs and options 2
Adds the allowAbsoluteUrls option.
This option defaults to true, so custom calculateDelay functions run only when retry is allowed by limit, methods, statusCodes, and errorCodes.
Performance 2
Large JSON bodies are decoded incrementally to reduce peak memory usage.
Large text bodies are decoded incrementally to reduce peak memory usage.
Behavior and default changes 1
For json and form request bodies, uploadProgress now emits granular per-chunk events.
Fixes and other changes 7
Request bodies are now preserved on cross-origin 307 and 308 redirects.
Fixes the setter dropping the value when a URL is set.
Fixes handling of abort signals added by handlers.
Fixed aborting during download progress.
Fixes a false ReadError on responses without Content-Length.
Fixes a completion race involving the stream cookie jar.
The init types were fixed.
got 1429 changes
Breaking changes 2
Shortcut methods no longer ignore handler errors.
Node.js 20 is now required; users who need to support Node.js 18 are advised to stay on Got v13.
Security 1
Different UNIX socket paths are now treated as different origins.
New APIs and options 3
Adds retryCount to the beforeRequest hook context.
Typed arrays are now supported as request bodies.
Adds support for zstd (Zstandard) compression.
Behavior and default changes 4
The beforeError hook now allows custom Error classes.
HTTPError messages now include the method and URL.
Validation error messages now include option names.
The followRedirect option now accepts a function.
Fixes and other changes 19
Empty PATCH, DELETE, and OPTIONS streams no longer auto-end, allowing callers to pipe or write a body without a write-after-end error.
Fixes TypeScript type inference for got.extend() when using the responseType option.
Fix the dnsLookup option type so it accepts Node.js dns.lookup.
Fixes socket reuse timing and DNS timing.
Path segments containing colons are no longer misidentified as absolute URLs.
Fixes TypeScript code not being built in 14.6.0.
Fixes afterResponse hook validation to allow null body values.
The beforeError hook is now called for ERR_UNSUPPORTED_PROTOCOL errors.
Fixes a silent hang when the hook returns a cached response with a FormData body.
Fixes body reassignment in beforeRetry hooks.
Fixes incorrect content-length when piping decompressed responses.
DNS timing is now zero when connecting to IP addresses.
Hook type definitions now reflect normalized runtime state.
Fixes the issue that caused HTTP/2 timings to be NaN.
Fixes preserving prefixUrl in hooks.
EPIPE errors now follow retry logic in the Promise API.
Fixes a race condition that could cause a retry after the promise settles.
Fixes unhandled rejections caused by stream validation errors.
Fixes timings.end being undefined when a stream is destroyed before completion.
got 133 changes
Breaking changes 2
The enableUnixSockets option now defaults to false.
Got now requires Node.js 16.
Behavior and default changes 1
Options can now be specified as undefined.
got 1258 changes
Breaking changes 26
An afterResponse hook that returns an invalid value now causes an error.
The beforeRetry hook now accepts only error and retryCount; options remain accessible through error.options.
Retrying with a consumed body now throws an error.
Got no longer automatically adds content-length for a ReadStream.
The lookup option is renamed to dnsLookup.
dnsLookupIpVersion now accepts 4, 6, or undefined instead of strings such as ipv4.
error.options is now enumerable.
got.extend now throws when an option does not accept undefined; undefined no longer preserves the old value.
Init hooks run only when an options object is passed explicitly.
The methodRewriting option's behavior is inverted.
The minimum supported Node.js version is 14; Node.js 12 is no longer supported.
Got exports an Option class with setters and getters for parsing and validating options; unknown options now throw, and error.options provides options available before the error.
options.agent can no longer be false; set its http, https, and http2 properties to false instead.
The url option used when paginating must be a URL instance.
A url option supplied during pagination must be absolute; prefixUrl is reset and will not be applied.
Got is now pure ESM, so projects and tools loading it must support and be configured for ESM.
The redirect event now receives updatedOptions first and plainResponse second.
redirectUrls now contains URL instances.
request.aborted is renamed to request.isAborted.
requestUrl now returns a URL instance.
Retries must now be declared with an object, such as retry.limit, rather than as a number.
retryWithMergedOptions in an afterResponse hook now throws RetryError instead of returning a Promise, allowing beforeRetry hooks to run.
The socketPath option is removed; use the unix: protocol instead.
stackAllItems now defaults to false.
Timeouts must now be declared with an object, such as timeout.request, rather than as a number.
Legacy Url instances are no longer supported; use WHATWG URL instead.
New APIs and options 9
The AfterResponseHook TypeScript type now accepts a generic argument.
error.code is defined.
More HTTPS options are supported.
The init hook accepts a second self argument pointing to an Options instance; custom options should be placed in options.context.
A parser for the Link header is added.
A read timeout is added.
A noise retry option is added.
A retry.backoffLimit option is added.
A new error type always triggers a new retry when thrown.
Behavior and default changes 5
Async generators can now be used as a request body.
The hook's options argument is now a cloned Request options instance, allowing access to the original options.
The context option can now be merged.
defaults.handlers no longer requires a default handler.
The pagination API is improved.
Fixes and other changes 18
Got no longer throws when handling custom stack traces.
A Node.js 16 bug that could hang Got streams is fixed.
got.paginate now calls init hooks.
A promise no longer hangs on an HTTP/2 timeout.
HTTP/2 remains disabled by default but can still be enabled with the http2 option; HTTP/2 requests require Node.js 15.10 or above.
The https.alpnProtocols option now takes effect.
An invalid IP returned early by lookup no longer causes an unhandled exception.
Missing once types are added for the Stream API.
Default pagination handling is fixed for an empty Link header.
Relative URLs are handled correctly when paginating.
ParseErrors are no longer uncaught on an initially successful response.
Promise shortcuts are fixed for responses with error status codes.
Request options are now reused correctly on retry.
The Cannot call end error is fixed when request returns a Writable.
response.complete is now correct when using cache.
Merging searchParams is fixed.
The url option is now reused correctly on retry in a rare case.
Username and password are now encoded correctly in URLs.
got 1138 changes
Breaking changes 24
Got now throws when a request is aborted by the server.
The option now accepts only an object with
http,httpsandhttp2properties;http2must be anhttp2wrapper.Agentinstance or undefined.The hook is now called on redirects.
The
cacheAdapteroption was renamed tocache; it is no longer passed to Keyv, so provide a Keyv instance to persist data.The TypeScript type
DefaultOptionswas renamed toDefaults.The option now defaults to a
CacheableLookupinstance and no longer accepts a Map-like instance.The property now gives a Got stream instead of a
ClientRequestinstance, providing properties such asdownloadProgress.The TypeScript type
GotRequestMethodwas renamed toGotRequestFunction.Errors thrown in
inithooks are converted toRequestErrorinstances, which expose Got options througherror.options.The TypeScript type
Defaultswas renamed toInstanceDefaults.Got now throws on leading slashes.
Got now requires Node.js 10.19 or later.
The TypeScript type
GotOptionswas renamed toOptions.Encoding applies only to the Got promise API again; set stream encoding with
stream.setEncoding(encoding).The pagination option is now stable and replaces the former
_paginationoption.Pagination now ignores the
resolveBodyOnlyoption.promise.json()now throwsParseError.Spaces in query strings are normalized as
+.The exported error name
GotErrorwas renamed toRequestError.The TypeScript type
DefaultRetryOptionswas renamed toRequiredRetryOptions.The TypeScript type
ResponseObjectwas renamed toResponse.Errors are no longer swallowed when using
stream.pipeline(got.stream(...), ...).Got is compatible with
tough-cookie@4.0.0.The option was removed along with support for Electron's net module; Got remains usable in Electron through electron.remote or Node.js shims.
Security 1
The authorization header no longer leaks.
New APIs and options 1
HTTP2 support is available but disabled by default; enable it with
http2: true.
Behavior and default changes 2
Use a
beforeRequesthook to modify the request URL because options passed toinitmay not have aurlproperty.Response headers can be modified while using
got.stream(...).
Fixes and other changes 10
Errors thrown in an
inithook are passed to thebeforeErrorhook.The hook now receives
options.context.Fixes a memory leak when using the cache feature.
The cache can now be used along with the
bodyoption.Cached responses are now decompressed.
Replacing the
cacheoption in a Got instance now takes effect.Passing already frozen options no longer causes Got to throw.
got.mergeOptions(...)now mergesURLSearchParamsinstances.Requests to UNIX sockets now include query strings.
User-provided options can now be reused.
got 1048 changes
Breaking changes 21
The baseUrl option is replaced by prefixUrl.
A canceled request with an incomplete response now throws.
Error properties previously exposed at the top level, including gotOptions and request details, are moved into error.options.
Response-related error properties, including headers, statusCode, body, and redirectUrls, are moved into error.response.
The Promise API property is renamed to isFromCache.
got.create() is removed; got.extend() can achieve the same thing.
got.mergeInstances() is removed; use an instance's extend() method instead.
Use undefined instead of null to omit a header.
Renames the Promise API property from .fromCache to .isFromCache.
Renames the stream option to isStream to clarify that it is a boolean.
The json option now accepts an object for the request body and no longer controls the response type; use .json() or responseType for JSON responses.
Got now requires Node.js 10, using Node.js 10-only APIs for more reliable stream handling.
Specifying body no longer infers the POST method; use got.post explicitly.
Replaces baseUrl with prefixUrl; when used, the url argument cannot be prefixed with a slash.
The url argument no longer accepts protocol-less URLs; provide a protocol such as https://.
The query option is replaced by searchParams.
Use responseType: 'buffer' instead of encoding: null to receive a Buffer.
Provides a callback option for calculating retry delay, replacing the callback form of retries.retry.
The retries.retry option is split; use retries.limit for the retry count.
Renames the query option to searchParams and makes it stricter.
The stream option is renamed to isStream.
New APIs and options 10
Adds Brotli support on Node.js 12 and later.
Adds an option for storing custom metadata across requests and hooks.
Allows using a cookie handler other than tough-cookie.
Adds an opt-in DNS cache.
Use responseType: 'buffer' instead of encoding: null to receive a Buffer.
Adds an option to ignore invalid cookies.
Custom instance creation and merging are simplified; extend() accepts multiple options or instances.
Adds an option to set the maximum number of redirects.
Adds an option for method rewriting on redirects.
Adds an isFromCache property to the stream API.
Behavior and default changes 6
The beforeRedirect hook now receives the response as its second argument.
The prefixUrl option can now be modified in hooks.
A failed redirect no longer retries from scratch.
The timeout option can now be modified in hooks.
URLSearchParams instances can now be merged.
The default user-agent header no longer includes the Got version.
Tooling 1
Got was rewritten in TypeScript and can provide its own type definitions.
Fixes and other changes 10
Response parsing no longer throws on 204 No Content.
Fixes response parsing when using the afterResponse hook.
Correctly handles promise- and stream-specific errors in the beforeError hook.
Retries inside afterResponse now trigger the beforeRetry hook.
Fixes cookies not being reset on redirects between different sites.
Got no longer throws on early lookups.
Fixes compatibility with Node.js 13.
Fixes a bug that could cause the Node.js process to hang.
Fixes port not being reset on redirect.
Fixes retry functionality and the default retry option value when a number is specified.
got 916 changes
Breaking changes 5
An Array is no longer supported as the body option when form: true; stringify the body yourself if needed.
The canceled property was renamed to isCanceled.
Got now requires Node.js 8, enabling use of async/await and WHATWG URL.
Calling .pipe() after the response has been emitted now throws an error, ensuring the whole response is received in flowing mode.
The retry option replaces retries and accepts a number or an object specifying retry counts, HTTP status codes, methods, and a retry decision function.
New APIs and options 5
A beforeRequest hook was added.
Creates niche-specific Got instances, such as an HTTP client for GitHub.
Creates Got instances with some options overridden.
The Promise API now emits a request event.
The Promise API now emits a response event.
Behavior and default changes 4
The body option now accepts any kind of object, not only plain objects.
Got now automatically sets the content-length header when body is a fs.createReadStream instance.
The timeout option was rewritten and can now set timeouts for individual request phases or for the whole request.
Passing null for the user-agent header removes the default user-agent header.
Fixes and other changes 2
Headers are now correctly proxied when piping got.stream().
Fixed caching when using the query option.
got 811 changes
Breaking changes 3
Passed headers with values null or undefined are excluded.
Protocol-less URLs now use HTTPS instead of defaulting to HTTP.
The useElectron option now defaults to false.
New APIs and options 4
Added a cache option with support for cache adapters.
Exposed got.CancelError.
Added download progress events.
Added upload progress events.
Behavior and default changes 1
The agent option now supports an object.
Fixes and other changes 3
Fixed .cancel() when a timeout exists.
Fixed some memory leaks.
Now uses the statusMessage returned by the endpoint.
got 713 changes
Breaking changes 4
An object body now requires either form or json for encoding; Got no longer defaults to URL encoding.
Got no longer throws HTTPError on 304 responses.
ParseError is now thrown only when parsing fails on 2xx responses.
Got now redirects on 307, 308, and 303 responses.
New APIs and options 4
Errors now include a protocol property.
In-progress requests can now be canceled.
Errors now include a url property.
Got now supports WHATWG URL.
Behavior and default changes 4
Errors now include response headers.
Redirect URLs are now included in errors and the response.
Retries are reduced in number and their delays are shorter.
The timeout option now applies to the whole request; individual request phases can also have their timeouts controlled.
Fixes and other changes 1
Got use in Electron has been improved.