Closed renovate-bot closed 2 years ago
Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 12.x releases. But if you manually upgrade to 12.x then Renovate will re-enable minor
and patch
updates automatically.
If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.
This PR contains the following updates:
^11.0.0
->^12.0.0
Release Notes
sindresorhus/got
### [`v12.0.0`](https://togithub.com/sindresorhus/got/releases/v12.0.0) [Compare Source](https://togithub.com/sindresorhus/got/compare/v11.8.3...v12.0.0) ##### Introducing Got v12.0.0 :tada: Long time no see! The latest Got version (v11.8.2) was released just in February ❄️ We have been working hard on squashing bugs and improving overall experience. If you find Got useful, you might want to [sponsor the Got maintainers](https://togithub.com/sindresorhus/got?sponsor=1). ##### This package is now pure ESM **Please [read this](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).** Also see [https://github.com/sindresorhus/got/issues/1789](https://togithub.com/sindresorhus/got/issues/1789). - **Please don't open issues about `[ERR_REQUIRE_ESM]` errors.** This is a problem with your setup, not Got. - Please don't open issues about using Got with Jest. Jest does not fully support ESM. - Pretty much any problem with loading this package is a problem with your bundler, test framework, etc, not Got. - If you use TypeScript, you will want to stay on Got v11 until TypeScript 4.6 is out. [Why.](https://togithub.com/microsoft/TypeScript/issues/46452) - If you use a bundler, make sure it supports ESM and that you have correctly configured it for ESM. - The Got issue tracker is not a support channel for your favorite build/bundler tool. ##### Required Node.js >=14 While working with streams, we encountered more Node.js bugs that needed workarounds. In order to keep our code clean, we had to drop Node.js v12 as the code would get more messy. We strongly recommend that you update Node.js to **v14 LTS**. ##### HTTP/2 support Every Node.js release, the native `http2` module gets more stable. Unfortunately there are still some issues on the Node.js side, so we decided to keep HTTP/2 disabled for now. We may enable it by default in Got v13. It is still possible to turn it on via the `http2` option. To run HTTP/2 requests, it is required to use Node.js **v15.10** or above. ##### Bug fixes Woah, we possibly couldn't make a release if we didn't fix some bugs! - Do not throw on custom stack traces ([#1491](https://togithub.com/sindresorhus/got/issues/1491)) [`49c16ee`](https://togithub.com/sindresorhus/got/commit/49c16ee54fb19ea7aa77e24ac8c2b602f0aad265) - Remove automatic `content-length` on ReadStream ([#1510](https://togithub.com/sindresorhus/got/issues/1510)) [`472b8ef`](https://togithub.com/sindresorhus/got/commit/472b8ef9d9fc7713b740981a8b1103a7a9111b26) - Fix promise shortcuts in case of error status code ([#1543](https://togithub.com/sindresorhus/got/issues/1543)) [`ff918fb`](https://togithub.com/sindresorhus/got/commit/ff918fb6dedb6d8b23421497ec890d43f45121b7) [`1107cc6`](https://togithub.com/sindresorhus/got/commit/1107cc625e4cc469276483316c48896a21f6251a) - Invert the `methodRewriting` option [`51d88a0`](https://togithub.com/sindresorhus/got/commit/51d88a0efed56760d116c5b911cea71e3265c787) - Fix `url` not being reused on retry in rare case ([#1487](https://togithub.com/sindresorhus/got/issues/1487)) [`462bc63`](https://togithub.com/sindresorhus/got/commit/462bc630015064fa4ad4358cf28d24f95e1c958b) - Fix hanging promise on HTTP/2 timeout ([#1492](https://togithub.com/sindresorhus/got/issues/1492)) [`a59fac4`](https://togithub.com/sindresorhus/got/commit/a59fac415ac013a48b1d514837628a5cf81d6878) - Prevent uncaught ParseErrors on initial successful response ([#1527](https://togithub.com/sindresorhus/got/issues/1527)) [`77df9c3`](https://togithub.com/sindresorhus/got/commit/77df9c33db5ba3126f54317171e1cfcfceefc3d5) - Throw an error when retrying with consumed body ([#1507](https://togithub.com/sindresorhus/got/issues/1507)) [`62305d7`](https://togithub.com/sindresorhus/got/commit/62305d77d3428b5c714d21b4bbee68cc75b5f787) - Fix a Node.js 16 bug that hangs Got streams [`06a2d3d`](https://togithub.com/sindresorhus/got/commit/06a2d3d7d8d4fcc6898b6364d1a18ca1d407092b) - Fix default pagination handling for empty Link header ([#1768](https://togithub.com/sindresorhus/got/issues/1768)) [`1e1e506`](https://togithub.com/sindresorhus/got/commit/1e1e50647e93d038a4cc6a9bbbfbf61165d8fd39) - Fix incorrect `response.complete` when using cache [`9e15d88`](https://togithub.com/sindresorhus/got/commit/9e15d887da3b065940bbc8ca38f9c748a0bbc75e) - Fix `Cannot call end` error when `request` returns a `Writable` [`226cc39`](https://togithub.com/sindresorhus/got/commit/226cc3995f6e16938163ebde24d8762e7dcd15e2) - Fix Request options not being reused on retry [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - Fix types being not compatible with CommonJS [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - Fix `got.paginate does not call init hooks` ([#1574](https://togithub.com/sindresorhus/got/issues/1574)) [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - Generate a new object when passing options to the native `https` module ([#1567](https://togithub.com/sindresorhus/got/issues/1567)) [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - Remove stream reuse check ([#1803](https://togithub.com/sindresorhus/got/issues/1803)) [`9ecc5ee`](https://togithub.com/sindresorhus/got/commit/9ecc5ee76f77aafd5100520d9d8789c491c8fb24) - Fix merging `searchParams` ([#1814](https://togithub.com/sindresorhus/got/issues/1814)) [`1018c20`](https://togithub.com/sindresorhus/got/commit/1018c2029eea1f5b75b5120265996f1c0b3c12ae) [`732e9bd`](https://togithub.com/sindresorhus/got/commit/732e9bd9406ba1c3dd64b445264e891f33fc0254) - Fix unhandled exception when lookup returns invalid IP early ([#1737](https://togithub.com/sindresorhus/got/issues/1737)) [`2453e5e`](https://togithub.com/sindresorhus/got/commit/2453e5e4213fe036a0108de3e4db414dcf2b4c30) - Fix relative URLs when paginating [`439fb82`](https://togithub.com/sindresorhus/got/commit/439fb82d2a07cece417a18c47e37cfdeaaf38db7) - Require url to be an instance of URL when paginating ([#1818](https://togithub.com/sindresorhus/got/issues/1818)) [`eda69ff`](https://togithub.com/sindresorhus/got/commit/eda69ff924a621e499d31cbc590993a32ddb48d3) - Fix `username` and `password` encoding in URL ([#1169](https://togithub.com/sindresorhus/got/issues/1169) [#1317](https://togithub.com/sindresorhus/got/issues/1317)) [`d65d0ca`](https://togithub.com/sindresorhus/got/commit/d65d0caf627e8d1f5367db34d7d9b55d332c1efb) - Clone raw options [`1c4cefc`](https://togithub.com/sindresorhus/got/commit/1c4cefc9b49f891712c3758f853d8c6214a1c904) - Fix invalid `afterResponse` return check [`cbc8902`](https://togithub.com/sindresorhus/got/commit/cbc8902) - Fix `https.alpnProtocols` not having an effect [`e1099fb`](https://togithub.com/sindresorhus/got/commit/e1099fb) ##### Improvements - Make the `context` option mergeable ([#1459](https://togithub.com/sindresorhus/got/issues/1459)) [`2b8ed1f`](https://togithub.com/sindresorhus/got/commit/2b8ed1f5a185f30603d24e2ceb8181782de3bc5a) - Add generic argument to AfterResponseHook TypeScript type ([#1589](https://togithub.com/sindresorhus/got/issues/1589)) [`6fc04a9`](https://togithub.com/sindresorhus/got/commit/6fc04a9b92f07b07b9fba010f2231a90082a039b) - Add read timeout ([#1518](https://togithub.com/sindresorhus/got/issues/1518)) [`e943672`](https://togithub.com/sindresorhus/got/commit/e9436720fcb32b77d39d5477b420b18083e41c02) *(blocked by [https://github.com/nodejs/node/issues/35923](https://togithub.com/nodejs/node/issues/35923))* - Improve the pagination API ([#1644](https://togithub.com/sindresorhus/got/issues/1644)) [`2675046`](https://togithub.com/sindresorhus/got/commit/2675046a83c7f03613f553a8da2912d491be900d) - Change the stackAllItems option to be false by default ([#1645](https://togithub.com/sindresorhus/got/issues/1645)) [`1120370`](https://togithub.com/sindresorhus/got/commit/1120370e05fd8d9e768677d8474d0c82cf91a6a6) - Throw when afterResponse hook returns an invalid value [`4f21eb3`](https://togithub.com/sindresorhus/got/commit/4f21eb3db705c90797ef8ee1503704f78fea3c1b) - Add `retry.backoffLimit` option [`41c4136`](https://togithub.com/sindresorhus/got/commit/41c4136632b9391adb3ac53332b312089bc4dc16) - Add `noise` retry option [`e830077`](https://togithub.com/sindresorhus/got/commit/e83007704670b5f567ca338c156441f6c569ecb5) - Enable more HTTPS options [`83575d5`](https://togithub.com/sindresorhus/got/commit/83575d590a119027d319bd9208681973087564a9) [`fe723a0`](https://togithub.com/sindresorhus/got/commit/fe723a0477dc02785a0b477e3d5f85d0233e5b84) (thanks [@Giotino](https://togithub.com/Giotino)) - Define `error.code` [`f27e8d3`](https://togithub.com/sindresorhus/got/commit/f27e8d331627074e76e4a9ec85a2c8d0a0625e5f) - Set `options.url` even if some options are invalid [`8d6a680`](https://togithub.com/sindresorhus/got/commit/8d6a6807883323a83ea5f126ca56b55d9ce5f299) - Improve memory usage when merging options [`2db5ec5`](https://togithub.com/sindresorhus/got/commit/2db5ec5d366efbbf9e0838eabfa6be774a0518a0) - Support async generators as body [`854430f`](https://togithub.com/sindresorhus/got/commit/854430f01350811fe8a0ccf20cd820aabfbd3926) [`3df52f3`](https://togithub.com/sindresorhus/got/commit/3df52f38edbadb45158c37d499817bc5486989c6) - Add missing `once` types for Stream API [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - New error type: `RetryError` which always triggers a new retry when thrown [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - `error.options` is now enumerable [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - `defaults.handlers` don't need a default handler now [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - Add a parser for the `Link` header [`3c23eea`](https://togithub.com/sindresorhus/got/commit/3c23eea5a096f6f8ea0edf3e2a27e1caca88acf9) - General code improvements [`a5dd9aa`](https://togithub.com/sindresorhus/got/commit/a5dd9aa37e7891b2620798560799c7f8bd380877) ##### Breaking changes ##### Improved option normalization - Got exports an `Option` class that is specifically designed to parse and validate Got options. It is made of setters and getters that provide fast normalization and more consistent behavior. When passing an option does not exist, Got will throw an error. In order to retrieve the options before the error, use `error.options`. ```js import got from 'got'; try { await got('https://httpbin.org/anything', { thisOptionDoesNotExist: true }); } catch (error) { console.error(error); console.error(error.options.url.href); // Unexpected option: thisOptionDoesNotExist // https://httpbin.org/anything } ``` - The `init` hook now accepts a second argument: `self`, which points to an `Options` instance. In order to define your own options, you have to move them to `options.context` in an [`init` hook](https://togithub.com/sindresorhus/got/blob/main/documentation/lets-make-a-plugin.md#authorization) or store them in `options.context` directly. - The `init` hooks are ran only when passing an options object explicitly. ```diff - await got('https://example.com'); // this will *not* trigger the init hooks + await got('https://example.com', {}); // this *will** trigger init hooks ``` - [`options.merge()`](2-options.md) replaced `got.mergeOptions` and `Request.normalizeArguments` ```diff - got.defaults.options = got.mergeOptions(got.defaults.options, {…}); + got.defaults.options.merge(…); ``` This fixes issues like [#1450](https://togithub.com/sindresorhus/got/issues/1450) - Legacy `Url` instances are not supported anymore. You need to use WHATWG URL instead. ```diff - await got(string, {port: 8443}); + const url = new URL(string); + url.port = 8443; + await got(url); ``` - No implicit timeout declaration. ```diff - await got('https://example.com', {timeout: 5000}) + await got('https://example.com', {timeout: {request: 5000}) ``` - No implicit retry declaration. ```diff - await got('https://example.com', {retry: 5}) + await got('https://example.com', {retry: {limit: 5}) ``` - `dnsLookupIpVersion` is now a number (4 or 6) or undefined ```diff - await got('https://example.com', {dnsLookupIpVersion: 'ipv4'}) + await got('https://example.com', {dnsLookupIpVersion: 4}) ``` - `redirectUrls` and `requestUrl` now give URL instances ```diff - request.requestUrl + request.requestUrl.origin + request.requestUrl.href + request.requestUrl.toString() ``` ```diff - request.redirectUrls[0] + request.redirectUrls[0].origin + request.redirectUrls[0].href + request.redirectUrls[0].toString() ``` - Renamed `request.aborted` to `request.isAborted` ```diff - request.aborted + request.isAborted ``` Reason: consistency with `options.isStream`. - Renamed the `lookup` option to `dnsLookup` ```diff - await got('https://example.com', {lookup: cacheable.lookup}) + await got('https://example.com', {dnsLookup: cacheable.lookup}) ``` - The `beforeRetry` hook now accepts only two arguments: `error` and `retryCount` ```diff await got('https://example.com', { hooks: { beforeRetry: [ - (options, error, retryCount) => { - console.log(options, error, retryCount); - } + (error, retryCount) => { + console.log(error.options, error, retryCount); + } ] } }) ``` The `options` argument has been removed, however it's still accessible via `error.options`. All modifications on `error.options` will be reflected in the next requests (no behavior change, same as with Got 11). - The `beforeRedirect` hook's first argument (options) is now a cloned instance of the Request options. This was done to make retrieving the original options possible: `plainResponse.request.options`. ```diff await got('http://szmarczak.com', { hooks: { beforeRedirect: [ (options, response) => { - console.log(options === response.request.options); //=> true [invalid! our original options were overriden] + console.log(options === response.request.options); //=> false [we can access the original options now] } ] } }) ``` - The `redirect` event now takes two arguments in this order: `updatedOptions` and `plainResponse`. ```diff - stream.on('redirect', (response, options) => …) + stream.on('redirect', (options, response) => …) ``` Reason: consistency with the `beforeRedirect` hook. - The `socketPath` option has been removed. Use the `unix:` protocol instead. ```diff - got('/containers/json', {socketPath: '/var/run/docker.sock'}) + got('unix:/var/run/docker.sock:/containers/json') + got('http://unix:/var/run/docker.sock:/containers/json') ``` - The `retryWithMergedOptions` function in an `afterResponse` hook no longer returns a `Promise`. It now throws `RetryError`, so this should this should be the last function being executed. This was done to allow `beforeRetry` hooks getting called. - You can no longer set `options.agent` to `false`. To do so, you need to define all the `options.agent` properties: `http`, `https` and `http2`. ```diff await got('https://example.com', { - agent: false + agent: { + http: false, + https: false, + http2: false + } }) ``` - When passing a `url` option when paginating, it now needs to be an absolute URL - the `prefixUrl` option is always reset from now on. The same when retrying in an `afterResponse` hook. ```diff - return {url: '/location'}; + return {url: new URL('/location', response.request.options.url)}; ``` There was confusion around the `prefixUrl` option. It was counterintuitive if used with the Pagination API. For example, it worked fine if the server replied with a relative URL, but if it was an absolute URL then the `prefixUrl` would end up duplicated. In order to fix this, Got now requires an absolute URL - no `prefixUrl` will be applied. - `got.extend(…)` will throw when passing some options that don't accept undefined - undefined no longer retains the old value, as setting undefined explicitly may reset the option ##### Documentation We have redesigned the documentation so it's easier to navigate and find exactly what you are looking for. We hope you like it :heart:Configuration
📅 Schedule: "after 9am and before 3pm" (UTC).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by WhiteSource Renovate. View repository job log here.