All Versions
32
Latest Version
Avg Release Cycle
13 days
Latest Release
1226 days ago

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.js http module, we have decided to officially drop support for it. Therefore, the useElectronNet 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 call stream.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 to RequestError 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 with http, https and http2 properties.
      While the http and https properties accept native http(s).Agent instances, the http2 property must be an instance of http2wrapper.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 of CacheableLookup. It cannot be a Map-like instance anymore. The underlying cacheable-lookup package has received many improvements, for example, it has received hosts file support! Additionally, the cacheAdapter option has been renamed to cache. 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 of RequestError. RequestErrors provide much more useful information, for example, you can access the Got options (through error.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 a url property. To modify the request URL you should use a beforeRequest 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 another init hook and a beforeRequest hook.

    • The error.request property is no longer a ClientRequest 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)

    1. Use error.code instead of error.message to compare errors (#981)
    2. Pass error thrown in the init hook to beforeError hook (#929)
    3. Errors have undefined body when using streams (#1138)
    4. Spaces should be normalized as + in query strings (#1113)
    5. Modify response headers while using got.stream(...) (#1129)
    6. Make error.request a Got stream (af0b147).

    Known bugs

    1. When some errors occur, the timings may indicate that the request was successful although it failed.
    2. When some errors occur, the downloadProgress object may show incorrect data.

    ๐Ÿ› Bug fixes

    1. Requests to UNIX sockets are missing query strings (#1036)
    2. beforeRequest hooks aren't called on redirects (#994)
    3. Errors are swallowed when using stream.pipeline(got.stream(...), ...) (#1026)
    4. Cannot use the cache along with the body option (#1021)
    5. Got doesn't throw on leading slashes (#1057)
    6. Got throws when passing already frozen options (#1050)
    7. Cannot type Got options properly due to missing types (#954) ๐Ÿ”€ 8. got.mergeOptions(...) doesn't merge URLSearchParams instances (#1011)
    8. The authorization header is leaking (#1090)
    9. Pagination should ignore the resolveBodyOnly option (#1140)
    10. Cannot reuse user-provided options (#1118)
    11. Broken with Node.js โ‰ฅ 13.10.0 (#1107)
    12. Cache is not decompressed (#1158)
    13. beforeRetry hooks are missing options.context (#1141) ๐Ÿ‘€ 15. promise.json() doesn't throw ParseError (#1069)
    14. Not compatible with [email protected] (#1131)
    15. Shortcuts give body from the failed request on token renewal (#1120)
    16. No effect when replacing the cache option in a Got instance (#1098)
    17. Memory leak when using cache (#1128)
    18. Got doesn't throw on aborted requests by the server (#1096)

    All changes

    v10.7.0...v11.0.0

  • 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), use got.stream(โ€ฆ).setEncoding(encoding) instead (to prevent confusion).
    • ๐Ÿ“‡ Renamed GotError to RequestError.
    • options.agent can no longer be an instance of http.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 to RequestErrors (why: RequestError provides much more useful information (e.g. Got options) than the usual TypeError etc.).

    • options._pagination has been renamed to options.pagination.

    • The options.url property will no longer be visible in init hooks (design limitation).

    • The error.request property is no longer a ClientRequest instance. Instead, it gives a Got stream.

    Types
    • ๐Ÿ”€ The ResponseObject type has been merged into the Response type.
    • 0๏ธโƒฃ Renamed the Defaults type to InstanceDefaults.
    • 0๏ธโƒฃ Renamed the DefaultOptions type to Defaults.
    • 0๏ธโƒฃ Renamed the DefaultRetryOptions type to RequiredRetryOptions.
    • ๐Ÿ“‡ Renamed the GotOptions type to Options.
    • ๐Ÿ“‡ Renamed the GotRequestMethod type to GotRequestFunction.

    โœจ 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

    1. Errors now have a request property (it's a Got stream).

    Known bugs

    1. The timings indicate that the request was successful (even though it errored).
    2. 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...v11.0.0-beta.1

  • v10.7.0 Changes

    March 24, 2020
    • ๐Ÿ›  Fix got.paginate(โ€ฆ) TypeScript typings (#1099) 0b798ea
    • Pass allItems and currentItems to _pagination.paginate() (#1100) 1cddd52
    • Do not ignore decompress-response when bundling (#1105) 88f973f
    • ๐Ÿ“œ Avoid parsing JSON twice in _pagination.transform (#1102) cf4fdad

    v10.6.0...v10.7.0

  • v10.6.0 Changes

    February 20, 2020

    v10.5.7...v10.6.0

  • v10.5.7 Changes

    February 16, 2020
    • ๐Ÿ›  Fix Init hooks not being called if extended acefaa4
  • v10.5.6 Changes

    February 16, 2020
    • ๐Ÿ›  Fix Init hook logic 64aeb40
    • โšก๏ธ Update dependencies 32e609f
  • 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
  • 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

    v10.5.1...v10.5.2