Changelog History
Page 3
-
v11.0.0 Changes
April 20, 2020๐ 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.net
๐ Due to the inconsistencies between the Electron's
net
module and the Node.jshttp
module, we have decided to officially drop support for it. Therefore, theuseElectronNet
option has been removed.You'll still be able to use Got in the Electron main process and in the renderer process through the
electron.remote
module 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
โช The
options.encoding
behavior 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 callstream.setEncoding(encoding)
.-got.stream('https://sindresorhus.com', {encoding: 'base64'});+got.stream('https://sindresorhus.com').setEncoding('base64');// Promises stay untouched await got('https://sindresorhus.com', {encoding: 'base64'});
๐ The error name
GotError
has been renamed toRequestError
for better readability and to comply with the documentation.-const {GotError} = require('got');+const {RequestError} = require('got');
The
agent
option now accepts only an object withhttp
,https
andhttp2
properties.
While thehttp
andhttps
properties accept nativehttp(s).Agent
instances, thehttp2
property must be an instance ofhttp2wrapper.Agent
or 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()+ }}
๐ฆ The
dnsCache
option is now set to a default instance ofCacheableLookup
. It cannot be aMap
-like instance anymore. The underlyingcacheable-lookup
package has received many improvements, for example, it has receivedhosts
file support! Additionally, thecacheAdapter
option 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() }
Errors thrown in
init
hooks will be converted to instances ofRequestError
.RequestError
s provide much more useful information, for example, you can access the Got options (througherror.options
), which is very useful when debugging.const got = require('got'); (async () => { try { await got('https://sindresorhus.com', { hooks: { init: [options => { if (!options.context) { throw new Error('You need to pass a
context
option'); } }] } }); } catch (error) { console.log(Request failed: ${error.message}
); console.log('Here are the options:', error.options); } })();The options passed in an
init
hook may not have aurl
property. To modify the request URL you should use abeforeRequest
hook 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
init
hook into anotherinit
hook and abeforeRequest
hook.The
error.request
property is no longer aClientRequest
instance. Instead, it gives a Got stream, which provides a set of useful properties.const got = require('got'); (async () => { try { await got('https://sindresorhus.com/notfound'); } catch (error) { console.log(
Request failed: ${error.message}
); console.log('Download progress:', error.request.downloadProgress); } })();
๐ Renamed TypeScript types
Some of the TypeScript types have been renamed to improve the readability:
| Old type | New type | |
ResponseObject
|Response
| 0๏ธโฃ |Defaults
|InstanceDefaults
| 0๏ธโฃ |DefaultOptions
|Defaults
| 0๏ธโฃ |DefaultRetryOptions
|RequiredRetryOptions
| |GotOptions
|Options
| |GotRequestMethod
|GotRequestFunction
|โจ Enhancements
0๏ธโฃ 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.
const got = require('got'); (async () =\> { const response = await got('https://nghttp2.org/httpbin/anything', {http2: true}); console.log(response.socket.alpnProtocol); //=\> 'h2'})();
๐ 1. The
merge
function is slow (#1016)- Use
error.code
instead oferror.message
to compare errors (#981) - Pass error thrown in the
init
hook tobeforeError
hook (#929) - Errors have undefined body when using streams (#1138)
- Spaces should be normalized as
+
in query strings (#1113) - Modify response headers while using
got.stream(...)
(#1129) - Make
error.request
a Got stream (af0b147).
Known bugs
- When some errors occur, the
timings
may indicate that the request was successful although it failed. - When some errors occur, the
downloadProgress
object may show incorrect data.
๐ Bug fixes
- Requests to UNIX sockets are missing query strings (#1036)
beforeRequest
hooks aren't called on redirects (#994)- Errors are swallowed when using
stream.pipeline(got.stream(...), ...)
(#1026) - Cannot use the
cache
along with thebody
option (#1021) - Got doesn't throw on leading slashes (#1057)
- Got throws when passing already frozen options (#1050)
- Cannot type Got options properly due to missing types (#954)
๐ 8.
got.mergeOptions(...)
doesn't mergeURLSearchParams
instances (#1011) - The
authorization
header is leaking (#1090) - Pagination should ignore the
resolveBodyOnly
option (#1140) - Cannot reuse user-provided options (#1118)
- Broken with Node.js โฅ 13.10.0 (#1107)
- Cache is not decompressed (#1158)
beforeRetry
hooks are missingoptions.context
(#1141) ๐ 15.promise.json()
doesn't throwParseError
(#1069)- Not compatible with
[email protected]
(#1131) - Shortcuts give body from the failed request on token renewal (#1120)
- No effect when replacing the
cache
option in a Got instance (#1098) - Memory leak when using
cache
(#1128) - Got doesn't throw on aborted requests by the server (#1096)
All changes
-
v11.0.0-beta.1 Changes
April 12, 2020$ npm install [email protected]
๐ The release notes will be improved in the final v11 release.
๐ Changes in beta 1:
๐ฅ Breaking
API
- โช
options.encoding
will no longer affect streams (reverting back to the Got 9 behavior), usegot.stream(โฆ).setEncoding(encoding)
instead (to prevent confusion). - ๐ Renamed
GotError
toRequestError
. options.agent
can no longer be an instance ofhttp.Agent
. Instead you need to pass:{ http: new http.Agent(โฆ), https: new https.Agent(โฆ), http2: new http2wrapper.Agent(โฆ) }
๐ The deprecated
useElectronNet
option has been removed.0๏ธโฃ
dnsCache
is now enabled by default.dnsCache
no longer can be a Map or a Keyv instance, instead you need to pass a CacheableLookup instance.Errors thrown in
init
hooks will be converted toRequestError
s (why:RequestError
provides much more useful information (e.g. Got options) than the usual TypeError etc.).options._pagination
has been renamed tooptions.pagination
.The
options.url
property will no longer be visible ininit
hooks (design limitation).The
error.request
property is no longer aClientRequest
instance. Instead, it gives a Got stream.
Types
- ๐ The
ResponseObject
type has been merged into theResponse
type. - 0๏ธโฃ Renamed the
Defaults
type toInstanceDefaults
. - 0๏ธโฃ Renamed the
DefaultOptions
type toDefaults
. - 0๏ธโฃ Renamed the
DefaultRetryOptions
type toRequiredRetryOptions
. - ๐ Renamed the
GotOptions
type toOptions
. - ๐ Renamed the
GotRequestMethod
type toGotRequestFunction
.
โจ Enhancements
๐ 1. Fixes #1016 ๐ 2. Fixes #981 ๐ 3. Fixes #932 ๐ 4. Fixes #929 ๐ 5. Fixes #1058 ๐ 6. Fixes #167 ๐ 7. Fixes #1138 ๐ 8. Fixes #1113 ๐ 9. Fixes #1129
- Errors now have a
request
property (it's a Got stream).
Known bugs
- The
timings
indicate that the request was successful (even though it errored). - The
downloadProgress
object may show incorrect data if the request has errored.
๐ Bug fixes
๐ 1. Fixes #1036 ๐ 2. Fixes #994 ๐ 3. Fixes #1026 ๐ 4. Fixes #1021 ๐ 5. Fixes #1057 ๐ 6. Fixes #1050 ๐ 7. Fixes #954 ๐ 8. Fixes #1011 ๐ 9. Fixes #1090 ๐ 10. Fixes #1140 ๐ 11. Fixes #1118
- โช
-
v10.7.0 Changes
March 24, 2020 -
v10.6.0 Changes
February 20, 2020- โ Add
allowGetBody
option to allow GET requests with payload (#1081) 526b4bb
- โ Add
-
v10.5.7 Changes
February 16, 2020- ๐ Fix Init hooks not being called if extended acefaa4
-
v10.5.6 Changes
February 16, 2020 -
v10.5.5 Changes
February 08, 2020- ๐ Fix merging pagination options 1f363b9
-
v10.5.4 Changes
February 08, 2020- ๐ Fix
_pagination
not falling back to defaults ff1dba1
- ๐ Fix
-
v10.5.3 Changes
February 08, 2020- ๐ Fix unhandled errors if throwing in an async handler 518d95a
-
v10.5.2 Changes
February 07, 2020- Forgot to include required
p-event
dependency 8373112
- Forgot to include required