Open
Conversation
a396da0 to
2d560e5
Compare
2d560e5 to
9632ee3
Compare
9632ee3 to
82f7916
Compare
4fdf954 to
c6ce366
Compare
c6ce366 to
07e23ba
Compare
07e23ba to
dec36c6
Compare
dec36c6 to
d201078
Compare
d201078 to
1bc9baa
Compare
1bc9baa to
23b8c96
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
1.14.3→2.0.1Release Notes
sindresorhus/ky (ky)
v2.0.1Compare Source
fetchimplementations (#858)29719912df9b7ev2.0.0Compare Source
Breaking
f1da0fcecdd45e{request, options, retryCount, ...}state object instead of separate arguments.prefixUrltoprefix, and allow leading slashes in input (#606)1f2ad7fbeforeErrorhook receive all errors, not justHTTPError(#829)101c74b.json()throw on empty bodies and204responses instead of returning an empty string (#854)1b8e1ffsearchParamswith input URL instead of replacing (#840)29e78fe433febd90c6d00New
totalTimeoutoption for an overall timeout across all retries (#848)c20d7c7baseUrloption for standard URL resolution (#606)1f2ad7fbaseUrluses standard URL resolution:/usersmeans origin-root,usersmeans relative to the base path.prefixdoes simple string joining first, so/usersandusersboth append to the prefix the same way. Use it only when you want that behavior.dataproperty toHTTPErrorwith pre-parsed response body (#823)1341f5cinithook (#841)87c6740NetworkErrorclass and tighten retry logic (#842)eaf0b80.json()(#830)94741a9replaceOptionhelper for.extend()(#846)bb8412erequestandoptionstobeforeErrorhook state (#835)01e0b85parseJsonoption (#849)3713ce8HTTPErrorfor opaque responses fromno-corsrequests (#847)1d15eb6onUploadProgresswhen request streams are unsupported (#845)1e38ff4Fixes
beforeRequesthooks being skipped when aRequestis returned (#832)aec65dbbeforeErrorhooks (#833)a541fc0Migration guide
Hook signatures
All hooks now receive a single state object instead of separate arguments.
hooks: { - beforeRequest: [(request, options) => { + beforeRequest: [({request, options}) => { request.headers.set('X-Custom', 'value'); }], - afterResponse: [(request, options, response) => { + afterResponse: [({request, options, response}) => { log(response.status); }], - beforeRetry: [({request, options, error, retryCount}) => { + beforeRetry: [({request, options, error, retryCount}) => { // Same as before - beforeRetry already used an object }], - beforeError: [(error) => { + beforeError: [({error}) => { return error; }], }prefixUrlrenamed toprefixLeading slashes in input are now allowed with
prefix. There's also a newbaseUrloption for standard URL resolution, which you may prefer overprefix.beforeErrorhook receives all errorsPreviously only received
HTTPError. Now receives all error types. Use type guards:.json()on empty responses.json()now throws a parse error on empty bodies and204responses instead of returning an empty string. This aligns with nativeJSON.parsebehavior and surfaces the real issue; your code expected JSON but the server sent none.Check the status before calling
.json()if you expect empty responses:Ky-specific options stripped from hooks
Ky-specific properties (
hooks,json,parseJson,stringifyJson,searchParams,timeout,throwHttpErrors,fetch) are no longer available on theoptionsobject passed to hooks. If you need access to these values, store them in a variable outside the hook or use thecontextoption to pass data between hooks.searchParamsmergingsearchParamsnow merges with existing query parameters in the input URL instead of replacing them.HTTPErrorresponse bodyerror.response.json()and other body methods no longer work since the body is now automatically consumed. Useerror.datainstead, which has the pre-parsed response body immediately available.This fixes resource leaks when catching
HTTPErrorwithout consuming the body (#633) and makes error details synchronously available (#642). We considered cloning the response to keep both paths working, but that doubles memory usage for error bodies and adds edge cases around locked/large streams for little benefit.error.responseis still available for headers and status.Upgrading from
2.0.0-0.json()on empty responsesThe behavior changed again from the prerelease.
.json()now throws instead of returningundefinedfor empty bodies and204responses. The return type is back toPromise<T>(no more| undefined).Thanks to @sholladay for helping with this update.
Configuration
📅 Schedule: (UTC)
* 7-16 * * 1,2,3,4)🚦 Automerge: Enabled.
♻ 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 was generated by Mend Renovate. View the repository job log.