sindresorhus

ky

๐ŸŒณ Tiny & elegant JavaScript HTTP client based on the Fetch API

by sindresorhus

TypeScript

TypeScript100%

Commit activity

Last 12 weeks ยท 102 commits

Full graph โ†’

Community health

4 of 6 standards met

Community profile โ†’
85
โœ“READMEโœ“Licenseโœ“Contributingโœ“Code of Conductโ—‹Issue Templateโ—‹PR Template

Recent PRs & issues

Active ยท 1 discussion ยท Last activity 1w ago
See all on GitHub โ†’
CHAPIBUNNY

Hi! is the heart of the request lifecycle (hooks โ†’ fetch โ†’ retry โ†’ after-response โ†’ errors), and it took me a while to map out how it fits with , and the error classes. I drafted a one-page (about 30 lines, just a table of and a note that the import cycles are type-only). Would you want that as a PR, maybe as a section in instead? If not, no worries, feel free to close. (Disclosure: I maintain RepoLens, a docs tool, and used it (v1.15.2) for the first draft; I checked everything against the source by hand.)

CHAPIBUNNY ยท 3h ago
jdanil

Problem The hook has the following description... This hook enables you to modify the request right before retry. ... but it cannot modify request . This is because the hook receives a frozen object. Note, the current behaviour is a bit inconsistent, as is shallow. So can be mutated for instance, but not . Context My main motivation for this feature is to work around #739. In my case, some users are behind middleboxes that don't support HTTP/2. I would prefer not to degrade the experience for all users (by removing completely), and only fallback where necessary. Ideally if could be modified, I could do something like this... I currently use a that wraps to achieve a similar outcome, but its quite complex. Proposal In and , pass the live options to the hooks, as we do with ... This would allow the hook to adjust the options uses for the next attempt. I'd be happy to contribute a PR if this change would be something you'd like to support. Alternatives Another option could be for to support this fallback behaviour internally, but I figured it would probably be useful for to be modifiable on retry like the rest of the request.

jdanil ยท 1w ago
quotentiroler

is , and CI runs it across a three-version Node matrix, with in each job. Measured on run 35139889608, Node 24 job, macos-latest: From that job's log: 1057 tests, of which the browser tests are 113s of AVA's reported time across 59 tests, against 428s for everything else. The browser tests drive ky in chromium, firefox and webkit, so the runner's Node version is not the variable. The same holds for , the build, and the test typecheck. All of it runs three times. Running the browser tests and the static checks once, with the matrix covering only the Node-side tests, would remove two of the three Playwright installs and two thirds of the browser work. Happy to send a PR, or to drop it if keeping the workflow identical across your repos is worth more than the minutes.

quotentiroler ยท 1w ago
sindresorhus

The option (Node.js/undici-specific) was being lost because it was listed in , which prevents options from being passed separately to . However, is a fetch-only option that the constructor doesn't accept. It must be passed directly to . Similarly, the option is also fetch-only in many environments. Fixes #687

sindresorhus ยท 2w ago
Structured data for AI agents

Repository: sindresorhus/ky. Description: ๐ŸŒณ Tiny & elegant JavaScript HTTP client based on the Fetch API Stars: 17130, Forks: 504. Primary language: TypeScript. Languages: TypeScript (100%). License: MIT. Topics: fetch, http-client, http-request, javascript, js, json, npm-package, request, rest, tiny, whatwg-fetch. Latest release: v2.2.0 (1w ago). Open PRs: 0, open issues: 1. Last activity: 1w ago. Community health: 85%. Top contributors: sindresorhus, sholladay, szmarczak, whitecrownclown, clicktodev, mgcrea, jabuj, poppinlp, joaovieira, cristobal and others.