Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): update got to version 11.0.0 #1533

Merged
merged 1 commit into from Apr 20, 2020
Merged

Conversation

greenkeeper[bot]
Copy link
Contributor

@greenkeeper greenkeeper bot commented Apr 20, 2020


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency got was updated from 10.7.0 to 11.0.0.

This version is not covered by your current version range.

If you don’t accept this pull request, your project will work just like it did before. However, you might be missing out on a bunch of new features, fixes and/or performance improvements from the dependency update.


Publisher: sindresorhus
License: MIT

Release Notes for v11.0.0

Introducing Got 11! 🎉 The last major version was announced in December last year ❄️, by the time huge amount of bugs got fixed. Also, there are many improvements, for example HTTP2 support is finally live! 🌐

If you find Got useful, you might want to sponsor the Got maintainers.


Want to see how it's done under the hood? Feel free to review the Got Rewrite: v10.7.0...master

Breaking changes

Removed Electron support

Due to the inconsistencies beetwen the Electron's net module and the Node.js http module, we have decided to officaly drop Electron support. Therefore, the useElectronNet option has been removed.

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: {...}
}

// Just remove the underscore from the beginning:

{
+ pagination: {...}
}

API

  • The options.encoding behavior has been reverted back to the one in Got 9.
    In other words, it's meant only for the Got promise.
    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 been given a 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(</span>Request failed: <span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">error</span>.<span class="pl-smi">message</span><span class="pl-pse">}</span></span><span class="pl-pds">);
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(</span>Request failed: <span class="pl-s1"><span class="pl-pse">${</span><span class="pl-smi">error</span>.<span class="pl-smi">message</span><span class="pl-pse">}</span></span><span class="pl-pds">);
console.log('Download progress:', error.request.downloadProgress);
}
})();

Renamed types

Some of the types have been renamed to improve the readability:

Old type New type
ResponseObject Response
Defaults InstanceDefaults
DefaultOptions Defaults
DefaultRetryOptions RequiredRetryOptions
GotOptions Options
GotRequestMethod GotRequestFunction

Enhancements

HTTP2 support is here! Excited? Yay! Unfortunately it's off by default to make the migration more smooth. 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)
  2. Use error.code instead of error.message to compare errors (#981)
  3. The retry logic should be moved into as-promise.ts (#932)
  4. Pass error thrown in the init hook to beforeError hook (#929)
  5. A way to customize cacheable-lookup (#1058)
  6. HTTP2 support (#167)
  7. Errors have undefined body when using streams (#1138)
  8. Spaces should be normalized as + in query strings (#1113)
  9. Modify response headers while using got.stream(...) (#1129)
  10. 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)
  9. The authorization header is leaking (#1090)
  10. Pagination should ignore the resolveBodyOnly option (#1140)
  11. Cannot reuse user-provided options (#1118)
  12. Broken with Node.js ≥ 13.10.0 (#1107)
  13. Cache is not decompressed (#1158)
  14. beforeRetry hooks are missing options.context (#1141)
  15. promise.json() doesn't throw ParseError (#1069)
  16. Not compatible with tough-cookie@4.0.0 (#1131)
  17. Shortcuts give body from the failed request on token renewal (#1120)
  18. No effect when replacing the cache option in a Got instance (#1098)
  19. Memory leak when using cache (#1128)
  20. Got doesn't throw on aborted requests by the server (#1096)
Commits

The new version differs by 33 commits.

There are 33 commits in total.

See the full diff


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper bot 🌴

@gr2m gr2m changed the title Update got to the latest version 🚀 build(deps): update got to version 11.0.0 Apr 20, 2020
@gr2m gr2m merged commit 2322a70 into master Apr 20, 2020
@gr2m gr2m deleted the greenkeeper/got-11.0.0 branch April 20, 2020 17:17
@semantic-release-bot
Copy link
Collaborator

🎉 This PR is included in version 17.0.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@semantic-release-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 17.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants