Skip to content
This repository was archived by the owner on Oct 10, 2026. It is now read-only.

chore(deps): update dependency ky to v2 - #255

Closed
renovate[bot] wants to merge 1 commit into
masterfrom
renovate/ky-2.x
Closed

renovate[bot] wants to merge 1 commit into
masterfrom
renovate/ky-2.x

Conversation

@renovate

@renovate renovate Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

This PR contains the following updates:

Package Change Age Confidence
ky ^0.25.1 → ^2.2.0 age confidence

Release Notes

sindresorhus/ky (ky)

v2.2.0

Compare Source

[!NOTE]
In init hooks, options.headers now has lowercase names. Read and delete headers with lowercase names, for example delete options.headers.authorization.

Improvements
  • Add maxResponseSize option 0d59458
    • Limits the response body size in bytes, counted after decompression. Exceeding it throws the new ResponseSizeError.
  • Let beforeRetry hooks change options for the next attempts (#​885) 242c327
    • Return {options: {...}} to change onUploadProgress, onDownloadProgress, timeout, fetch, or throwHttpErrors. For example, retry a failed upload without upload progress.
  • Respect Retry-After and rate-limit headers when retry.shouldRetry returns true d1c921f
  • Run beforeError hooks for errors thrown while reading the response body 323b98f 50c3810
    • A connection that drops while .json(), .text(), etc. reads the body is now a NetworkError.
  • Support onUploadProgress and streamed Request bodies in Bun and Deno 83c711c
  • Validate options and report clear errors 3ded2aa
    • Invalid options now throw a TypeError that names the option, instead of being silently ignored or failing later with an internal error. This includes null, non-array hooks, and invalid timeout and retry values.
    • Invalid options and errors thrown by init hooks now reject the returned promise instead of throwing synchronously.
  • Improve TypeScript types 51b3177 52b8f93 f4886ca 481f6f7
    • Accept readonly arrays and explicit undefined for all options, allow custom error names, and fix the .clone() and .bytes() return types.
Fixes
  • Fix aborts and timeouts in many edge cases e1b088e 2f0a3fb 7c1272b 82fa84c 3f0e330
    • User aborts and timeouts now also cancel requests returned from hooks, interrupt pending hooks and body reads, and are no longer reported as NetworkError and retried in Chromium. totalTimeout is now enforced when the response or body arrives after the deadline.
  • Fix searchParams with a Request input dropping its body and options such as credentials b4bdecc 4e0bf0b
  • Fix option merging in .extend() and init hooks e06d351 0655b9d c5dc4e6 88e2432
    • Class instances, such as an undici Agent as dispatcher or a Date in json, are no longer turned into plain objects. Header names are now matched case-insensitively. Changes made in .extend() callbacks and init hooks no longer leak into other requests.
  • Fix many replaceOption() edge cases cc9b5a3 d6e049a deb5a33
  • Fix parseJson being ignored by response.clone().json() and when using onDownloadProgress c6c5dbf 015ef95
  • Fix progress events, including wrong totalBytes for compressed responses and missing response properties with onDownloadProgress d89c8c8 e893f16 de278ae
  • Fix onUploadProgress breaking uploads without request stream support, and keepalive and no-cors requests 6520f64 06ebf18
  • Fix fetch: window.fetch throwing "Illegal invocation" in browsers 92ef60e
  • Fix isTimeoutError() and the other type guards matching unrelated errors with the same name d636438
  • Fix request on Ky errors being an internal clone instead of the request that was sent 619c427 ec3d17f

v2.1.0

Compare Source

Improvements
Fixes
  • Fix progress callbacks for empty request and response bodies (#​881) 99644d0
  • Fix signal replacement when extending instances (#​880) 0bda554
  • Fix extend() dropping numeric retry limit when merging with an object (#​867) 06375ef
  • Fix handling of Safari errors with domains 61d6d66

v2.0.2

Compare Source

  • Fix init hook URLSearchParams deletions add0703
  • Fix tuple searchParams mutations leaking across init-hook requests (#​861) 346f898

v2.0.1

Compare Source

  • Improve compatibility with custom fetch implementations (#​858) 2971991
  • Fix fetch option forwarding 2df9b7e

v2.0.0

Compare Source

Breaking
New
Fixes
  • Fix beforeRequest hooks being skipped when a Request is returned (#​832) aec65db
  • Ignore non-Errors returned by beforeError hooks (#​833) a541fc0

Migration 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;
	}],
}
prefixUrl renamed to prefix
-ky('users', {prefixUrl: 'https://example.com/api/'});
+ky('users', {prefix: 'https://example.com/api/'});

Leading slashes in input are now allowed with prefix. There's also a new baseUrl option for standard URL resolution, which you may prefer over prefix.

beforeError hook receives all errors

Previously only received HTTPError. Now receives all error types. Use type guards:

+import {isHTTPError} from 'ky';

hooks: {
	beforeError: [
-		(error) => {
-			const {response} = error;
+		({error}) => {
+			if (isHTTPError(error)) {
+				const {response} = error;
+			}

			return error;
		}
	]
}
.json() on empty responses

.json() now throws a parse error on empty bodies and 204 responses instead of returning an empty string. This aligns with native JSON.parse behavior 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:

const response = await ky('https://example.com/api');

if (response.status !== 204) {
    const data = await response.json();
}
Ky-specific options stripped from hooks

Ky-specific properties (hooks, json, parseJson, stringifyJson, searchParams, timeout, throwHttpErrors, fetch) are no longer available on the options object passed to hooks. If you need access to these values, store them in a variable outside the hook or use the context option to pass data between hooks.

searchParams merging

searchParams now merges with existing query parameters in the input URL instead of replacing them.

// v1: searchParams replaces ?existing=1
// v2: searchParams merges with ?existing=1
ky('https://example.com?existing=1', {searchParams: {added: 2}});
// => https://example.com?existing=1&added=2
HTTPError response body

error.response.json() and other body methods no longer work since the body is now automatically consumed. Use error.data instead, which has the pre-parsed response body immediately available.

-const body = await error.response.json();
-console.log(body.message);
+console.log(error.data.message);

This fixes resource leaks when catching HTTPError without 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.response is still available for headers and status.

Upgrading from 2.0.0-0
.json() on empty responses

The behavior changed again from the prerelease. .json() now throws instead of returning undefined for empty bodies and 204 responses. The return type is back to Promise<T> (no more | undefined).


Thanks to @​sholladay for helping with this update.


v1.14.3

Compare Source

  • Fix empty context object being added to merged json body d7f7e73

v1.14.2

Compare Source


v1.14.1

Compare Source


v1.14.0

Compare Source


v1.13.0

Compare Source

Improvements
Fixes

v1.12.0

Compare Source

Improvements
Fixes
  • Fix dispatcher option being ignored (#​757) 5a3fc90
  • Fix hooks field incorrectly included in NormalizedOptions (#​726) (#​756) 0f2f00a
  • Fix searchParams option merging with URLSearchParams instances (#​755) c847eec
  • Fix signal merging when using both instance and request options (#​751) 2b0a100
  • Fix FormData content-type boundary regeneration when retrying in hooks (#​752) d02b636

v1.11.0

Compare Source

  • Improve progress events for onDownloadProgress and onUploadProgress (#​736) 60958f9
  • Fix hang on stream request cleanup in Node.js (#​741) 9a89a35

v1.10.0

Compare Source


v1.9.1

Compare Source


v1.9.0

Compare Source


v1.8.2

Compare Source

  • Gracefully handle AbortSignal.any() not being available (#​711) 24eec6f

v1.8.1

Compare Source


v1.8.0

Compare Source


v1.7.5

Compare Source

  • Fix options.method being undefined in normalized options (#​671) 762ea4c

v1.7.4

Compare Source

  • Fix handling of a signal that is already aborted before the request begins (#​663) 6d06338

v1.7.3

Compare Source

v1.7.2

Compare Source

v1.7.1

Compare Source

v1.7.0

Compare Source

v1.6.0

Compare Source

v1.5.0

Compare Source

v1.4.0

Compare Source

v1.3.0

Compare Source

v1.2.4

Compare Source

v1.2.3

Compare Source

  • TypeScript: Fix usage with exactOptionalPropertyTypes config and compatibility with TypeScript 5.4 (#​565) 08f912d

v1.2.2

Compare Source

  • Fix missing type dependency c0a4dfa

v1.2.1

Compare Source

v1.2.0

Compare Source

Improvements
FIxes
  • Fix the retryCount option retrying an incorrect amount (#​547) 917ab12

v1.1.3

Compare Source

  • Export the KyInstance type 16eb51d

v1.1.2

Compare Source

v1.1.1

Compare Source

  • Fix support for environments that add custom fetch options (#​536) e93bc6d

v1.1.0

Compare Source

  • Add retry.delay option to control the time between retries (#​533) c6181ef

v1.0.1

Compare Source

  • Change Options and NormalizedOptions TypeScript types back to be interface 4d63a21

v1.0.0

Compare Source

Breaking
  • Require Node.js 18 (when used in Node.js) a8a3a26
Improvements
  • Ky can now run natively in Node.js without any polyfills 🎉
    • This is thanks to Node.js 18+ having built-in support for fetch.
    • This means ky-universal is no longer needed.

v0.33.3

Compare Source

  • Fix compatibility with native Fetch being disabled on Node.js (#​494) 00e45d0

v0.33.2

Compare Source

v0.33.1

Compare Source

  • Fix compatibility with Unidici ae2fe07

v0.33.0

Compare Source

v0.32.2

Compare Source

v0.32.1

Compare Source

  • Don't return empty string for .json() if Transfer-Encoding is chunked (#​464) 195e0e2

v0.32.0

Compare Source

v0.31.4

Compare Source

  • Fix Firefox compatibility for the onDownloadProgress option bccbfdb

v0.31.3

Compare Source

  • Fix Node.js compatibility 0b141f1

v0.31.2

Compare Source

v0.31.1

Compare Source

  • Fix copying response body with 204 status code when using onDownloadProgress (#​444) d48ed95

v0.31.0

Compare Source

Breaking
  • Require Node.js 14 when used in Node.js e557973
Improvements
Fixes
  • Fix response details getting lost when using onDownloadProgress (#​441) f34fb1f

v0.30.0

Compare Source

  • Allow overriding Content-Type header for JSON requests (#​429) d00864f

v0.29.0

Compare Source

v0.28.7

Compare Source

v0.28.6

Compare Source

v0.28.5

Compare Source

  • Export more TypeScript types ad991fa

v0.28.4

Compare Source

v0.28.3

Compare Source

v0.28.2

Compare Source

v0.28.1

Compare Source

v0.28.0

Compare Source

Breaking
  • Make HTTPError and TimeoutError named exports 6ec7fd7
Improvements
Fixes
  • Fix merging of searchParams in .create() and .extend() (#​335) b3c9e88
  • Throw timeouts even if throwHttpErrors option is false (#​334) eefcde5
Meta

v0.27.0

Compare Source

v0.26.0

Compare Source

Breaking
Improvements
Fixes
  • Fix aborting when onDownloadProgress throws an exception (#​301) 87c94fd
  • Fix support for ky.stop as return type in BeforeRetryHook TypeScript type (#​307) b86ff0a
  • Fix BeforeRetryHook and NormalizedOptions TypeScript type definitions (#​308) 5da3da0
Docs

Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • 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.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@renovate
renovate Bot force-pushed the renovate/ky-2.x branch from 0037d65 to d1efc79 Compare August 28, 2026 18:47
@socket-security

socket-security Bot commented Aug 28, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedky@​0.25.1 ⏵ 2.2.099100100 +192 +6100

View full report

@renovate
renovate Bot force-pushed the renovate/ky-2.x branch from d1efc79 to 14942f2 Compare October 9, 2026 08:26
@danielroe danielroe closed this Oct 10, 2026
@renovate

renovate Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor Author

Renovate Ignore Notification

Because you closed this PR without merging, Renovate will ignore this update. You will not get PRs for any future 2.x releases. But if you manually upgrade to 2.x then Renovate will re-enable minor and patch updates automatically.

If you accidentally closed this PR, or if you changed your mind: rename this PR to get a fresh replacement PR.

@renovate
renovate Bot deleted the renovate/ky-2.x branch October 10, 2026 09:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant