This repository was archived by the owner on Jun 7, 2022. It is now read-only.
Update dependency got to v12 #486
Open
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.
This PR contains the following updates:
^10.6.0->^12.1.0Test plan: CI should pass with updated dependencies. No review required: this is an automated dependency update PR.
Release Notes
sindresorhus/got
v12.1.0Compare Source
Improvements
response.ok(#2043)22d58fb{throwHttpErrors: false}Fixes
861ccd9v12.0.4Compare Source
bb8eca9v12.0.3Compare Source
jsonoption (#2015)eb045bfv12.0.2Compare Source
encodingoption with{responseType: 'json'}(#1996)0703318v12.0.1Compare Source
nockcompatibility (#1959)bf39d2cRequestTypeScript type (#1940)0f9f2b8v12.0.0Compare Source
Introducing Got v12.0.0 🎉
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.
This package is now pure ESM
Please read this. Also see https://github.com/sindresorhus/got/issues/1789.
[ERR_REQUIRE_ESM]andMust use import to load ES Moduleerrors. This is a problem with your setup, not Got.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
http2module 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
http2option.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!
49c16eecontent-lengthon ReadStream (#1510)472b8efff918fb1107cc6methodRewritingoption51d88a0urlnot being reused on retry in rare case (#1487)462bc63a59fac477df9c362305d706a2d3d1e1e506response.completewhen using cache9e15d88Cannot call enderror whenrequestreturns aWritable226cc393c23eea3c23eeagot.paginate does not call init hooks(#1574)3c23eeahttpsmodule (#1567)3c23eea9ecc5eesearchParams(#1814)1018c20732e9bd2453e5e439fb82eda69ffusernameandpasswordencoding in URL (#1169 #1317)d65d0ca1c4cefcafterResponsereturn checkcbc8902https.alpnProtocolsnot having an effecte1099fbImprovements
contextoption mergeable (#1459)2b8ed1f6fc04a9e943672(blocked by https://github.com/nodejs/node/issues/35923)267504611203704f21eb3retry.backoffLimitoption41c4136noiseretry optione83007783575d5fe723a0(thanks @Giotino)error.codef27e8d3options.urleven if some options are invalid8d6a6802db5ec5854430f3df52f3oncetypes for Stream API3c23eeaRetryErrorwhich always triggers a new retry when thrown3c23eeaerror.optionsis now enumerable3c23eeadefaults.handlersdon't need a default handler now3c23eeaLinkheader3c23eeaa5dd9aaBreaking changes
Improved option normalization
Optionclass 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.inithook now accepts a second argument:self, which points to anOptionsinstance.In order to define your own options, you have to move them to
options.contextin aninithook or store them inoptions.contextdirectly.inithooks are ran only when passing an options object explicitly.options.merge()replacedgot.mergeOptionsandRequest.normalizeArgumentsThis fixes issues like #1450
Urlinstances are not supported anymore. You need to use WHATWG URL instead.dnsLookupIpVersionis now a number (4 or 6) or undefinedredirectUrlsandrequestUrlnow give URL instancesrequest.abortedtorequest.isAbortedReason: consistency with
options.isStream.lookupoption todnsLookupbeforeRetryhook now accepts only two arguments:errorandretryCountawait got('https://example.com', { hooks: { beforeRetry: [ - (options, error, retryCount) => { - console.log(options, error, retryCount); - } + (error, retryCount) => { + console.log(error.options, error, retryCount); + } ] } })The
optionsargument has been removed, however it's still accessible viaerror.options. All modifications onerror.optionswill be reflected in the next requests (no behavior change, same as with Got 11).beforeRedirecthook'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.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] } ] } })redirectevent now takes two arguments in this order:updatedOptionsandplainResponse.Reason: consistency with the
beforeRedirecthook.socketPathoption has been removed. Use theunix:protocol instead.retryWithMergedOptionsfunction in anafterResponsehook no longer returns aPromise.It now throws
RetryError, so this should this should be the last function being executed.This was done to allow
beforeRetryhooks getting called.options.agenttofalse.To do so, you need to define all the
options.agentproperties:http,httpsandhttp2.await got('https://example.com', { - agent: false + agent: { + http: false, + https: false, + http2: false + } })urloption when paginating, it now needs to be an absolute URL - theprefixUrloption is always reset from now on. The same when retrying in anafterResponsehook.There was confusion around the
prefixUrloption. 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 theprefixUrlwould end up duplicated. In order to fix this, Got now requires an absolute URL - noprefixUrlwill 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 optionDocumentation
We have redesigned the documentation so it's easier to navigate and find exactly what you are looking for. We hope you like it ❤️
v11.8.5Compare Source
v11.8.3Compare Source
9463bb6HTTPErrormissing.codeproperty (#1739)0e167b8v11.8.2Compare Source
dnsCacheoption lazy (#1529)3bd245fThis slightly improves Got startup performance and fixes an issue with Jest.
v11.8.1Compare Source
4c815c3v11.8.0Compare Source
0onstat(#1488)7acd380beforeRetryallows stream body if different from original (#1501)3dd2273390b145v11.7.0Compare Source
Improvements
pfxHTTPS option (#1364)c33df7fbodyafterbeforeRequest(#1453)e1c18447bc69d9Fixes
88b32eapromise.json()c97ce7c52de13bv11.6.2Compare Source
Bug fixes
prefixUrloption from parent if it'sundefined(#1448)a3da70a29d4e32c126ff1Docs
2b352d3f248618RequestErrorlinks3ed4af6Tests
27470b5v11.6.1Compare Source
Fixes
options.porton redirect (#1439)408e22aMeta
5031843d12d6afv11.6.0Compare Source
Improvements
retrystream event (#1384)7072198http-cache-semanticsoptions2e2295fCancelErrorinheritRequestError1f132e8retryAftertoRetryObject643a305eaf1e02cacheOptionsproperty9c16d90Bug fixes
6e1aeaeDocs
f7bbc37CancelErrordocs28c400fREADME(#1425)38bbb04v11.5.2Compare Source
Docs
a3e171crequestmigration guide (#1387)a7483439a309bdBug fixes
e02845fdnsCache: truehaving no effect043c950v11.5.1Compare Source
Enhancements
http2-wrapperto1.0.0-beta.5.016e7f03f7a137961d6f61Bug fixes
2d966791ef053dDocs
readme.md4ebd26abd2d532c833939559526e4083347v11.5.0Compare Source
Improvements
backoffoption to pagination (#1182)4be7446b9a855d476c0268d697bcb51d836Fixes
676be6dac5f67dresponseevent not being emitted on cache verify request (#1305)da4769ef33e8bce1afe82aeb2e07Docs
beforeRequesthook779062a044767ev11.4.0Compare Source
934211f7dcd1455028c1104f3ea4The server aborted pending requestrejection728aef9ECONNRESETcode to an abort errord325d35prefixUrlnot working when theurlargument is empty8d3412asearchParamsoption4dbada98f775c7v11.3.0Compare Source
httpsoptions (#1304)c98f0d7cb4da8ddnsLookupIpVersionoption (#1264)7f643bbv11.2.0Compare Source
responseType(#1276)b9ba18abeforeRequesthook (#1293)d8c00cf2ccc4c2readyevent if the file descriptor is already opened (#1289)2c8fe19697de37v11.1.4Compare Source
3f125f1cacheable-lookupto 5.0.39770e5448bbb36options.rejectUnauthorizedin the documentation9b04963responseTypeset toundefined0e8582f6f84051got.paginate()an alias forgot.paginate.each()5480b31761b8e0decompress-responseto6.0.0c2bc014lolexto@sinonjs/fake-timers(#1270)df333ddcalculateDelaypromisable (#1266)3745efcv11.1.3Compare Source
request.abort()(#1242)ab338a7hostheader on redirect (#1241)8ff71d97dbb9ee91aa0acsearchParamsin merge (#1208)7d7361c886227047c1afe5131dc2v11.1.2Compare Source
Bug fixes
options.dnsCacheby default79507c2Enhancements
822bfa705ff878v11.1.1Compare Source
50ef99agot.mergeOptions()regression157e02b7b19e8foptions.responseTypeoptional when using a template9ed0a39v11.1.0Compare Source
pagination.stackAllItemsoption (#1214)c1208d1c127f5b278c421v11.0.3Compare Source
Fixes
4344c3ab927e2doptions.searchParamsduplicates429db40.abort()on a destroyed request63c1b72Docs
16ff82fcacheanddnsCachecan befalse7c5290dv11.0.2Compare Source
response.statusMessagebeing null965bd03http2-wrapperdependency to1.0.0-beta.4.44e8de8eMergeas it's stricter than the intersection operatord3b972e8501c69options.body835c70bv11.0.1Compare Source
Fixed two regressions:
HTTPErrors have unspecified response body (#1162)Improved TypeScript types for errors inherited from
RequestErrorv11.0.0Compare Source
Introducing Got 11! 🎉 The last major version was in December last year. ❄️ Since then, a huge amount of bugs has been fixed. There are also many new features, for example, HTTP2 support is finally live! 🌐
If you find Got useful, you might want to sponsor the Got maintainers.
Breaking changes
Removed support for
electron.netDue to the inconsistencies between the Electron's
netmodule and the Node.jshttpmodule, we have decided to officially drop support for it. Therefore, theuseElectronNetoption has been removed.You'll still be able to use Got in the Electron main process and in the renderer process through the
electron.remotemodule or if you use Node.js shims.The Pagination API is now stable
We haven't seen any bugs yet, so please give it a try!
If you want to leave some feedback, you can do it here. Any suggestion is greatly appreciated!
{ - _pagination: {...} + pagination: {...} }API
options.encodingbehavior has been reverted back to the Got 9 behavior.In other words, the options is only meant for the Got promise API.
To set the encoding for streams, simply call
stream.setEncoding(encoding).GotErrorhas been renamed toRequestErrorfor better readability and to comply with the documentation.agentoption now accepts only an object withhttp,httpsandhttp2properties.While the
httpandhttpsproperties accept nativehttp(s).Agentinstances, thehttp2property must be an instance ofhttp2wrapper.Agentor be undefined.{ - agent: new https.Agent({keepAlive: true}) } { + agent: { + http: new http.Agent({keepAlive: true}), + https: new https.Agent({keepAlive: true}), + http2: new http2wrapper.Agent() + } }dnsCacheoption is now set to a default instance ofCacheableLookup. It cannot be aMap-like instance anymore. The underlyingcacheable-lookuppackage has received many improvements, for example, it has receivedhostsfile support! Additionally, thecacheAdapteroption has been renamed tocache. Note that it's no longer passed to Keyv, so you need to pass a Keyv instance it if you want to save the data for later.{ - dnsCache: new CacheableLookup({ - cacheAdapter: new Map() - }) } { + dnsCache: new CacheableLookup({ + cache: new Keyv({ + cacheAdapter: new Map() + }) + }) } // Default: { dnsCache: new CacheableLookup() }inithooks will be converted to instances ofRequestError.RequestErrors provide much more useful information, for example, you can access the Got options (througherror.options), which is very useful when debugging.inithook may not have aurlproperty. To modify the request URL you should use abeforeRequesthook instead.{ hooks: { - init: [ + beforeRequest: [ options => { options.url = 'https://sindresorhus.com'; } ] } }Note that this example shows a simple use case. In more complicated algorithms, you need to split the
inithook into anotherinithook and abeforeRequesthook.error.requestproperty is no longer aClientRequestinstance. Instead, it gives a Got stream, which provides a set of useful properties.Renamed TypeScript types
Some of the TypeScript types have been renamed to improve the readability:
ResponseObjectResponseDefaultsInstanceDefaultsDefaultOptionsDefaultsDefaultRetryOptionsRequiredRetryOptionsGotOptionsOptionsGotRequestMethodGotRequestFunctionEnhancements
HTTP2 support is here! Excited? Yay! Unfortunately, it's off by default to make the migration smoother. Many Got users have set up their own Agents and we didn't want to break them. But fear no more, it will come enabled by default in Got 12.
mergefunction is slow (#1016)error.codeinstead oferror.messageto compare errors (#981)inithook tobeforeErrorhook (#929)+in query strings (#1113)got.stream(...)(#1129)error.requesta Got stream (af0b147).Known bugs
timingsmay indicate that the request was successful although it failed.downloadProgressobject may show incorrect data.Bug fixes
beforeRequesthooks aren't called on redirects (#994)stream.pipeline(got.stream(...), ...)(#1026)cachealong with thebodyoption (#1021)got.mergeOptions(...)doesn't mergeURLSearchParamsinstances (#1011)authorizationheader is leaking (#1090)resolveBodyOnlyoption (#1140)beforeRetryhooks are missingoptions.context(#1141)promise.json()doesn't throwParseError(#1069)tough-cookie@4.0.0(#1131)cacheoption in a Got instance (#1098)cache(#1128)All changes
v10.7.0Compare Source
got.paginate(…)TypeScript typings (#1099)0b798eaallItemsandcurrentItemsto_pagination.paginate()(#1100)1cddd52decompress-responsewhen bundling (#1105)88f973f_pagination.transform(#1102)cf4fdadConfiguration
📅 Schedule: Branch creation - "on the 1st through 7th day of the month" in timezone America/Los_Angeles, Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, 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 Mend Renovate. View repository job log here.