Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions packages/plugin-protocol-http/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ Documentation links:

[Agent parameters](https://undici.nodejs.org/#/docs/api/Client?id=parameter-clientoptions).

### Headers interface

Previously, node-fetch shipped with a [custom implementation](https://github.com/node-fetch/node-fetch/blob/v2.7.0/src/headers.js) of the `Headers` interface, which included several non-standard, spec-incompatible methods.

These methods are no longer supported, as the library now relies on the native `Headers` interface.

### Headers with the same name

The behavior for combining multiple headers with the same name has changed.

`node-fetch` returned an array of values.

The native Headers interface returns a single string, with values joined by `, `.

As a result, header values are always of type `string` now.

### Undici version

The library now explicitly uses fetch from undici.

undici has been moved to `peerDependencies`, so you must install it yourself when using `tinkoff/request`.

Choose an undici version compatible with your Node.js runtime (check `engine` field in package.json of required undici version).

### Jest

In jest-environment-jsdom there is no fetch. Use jsdom patching with undici’s fetch, as it is the most spec-compatible:
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin-protocol-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
},
"devDependencies": {
"@types/node": "^18.0.0",
"undici": "^5.0.0"
"undici": "^7.16.0"
},
"peerDependencies": {
"@tinkoff/request-core": "0.x"
"@tinkoff/request-core": "0.x",
"undici": ">=6"
},
"module": "lib/index.es.js"
}
4 changes: 2 additions & 2 deletions packages/plugin-protocol-http/src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { RequestInit, RequestInfo, fetch as undiciFetch } from "undici";
import { RequestInit, RequestInfo, fetch as undiciFetch } from 'undici';

const fetch = (input: RequestInfo, init?: RequestInit) => {
return (<typeof undiciFetch>globalThis.fetch)(input, init);
return undiciFetch(input, init);
};

const { Headers, Request, Response } = globalThis;
Expand Down
15 changes: 4 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1513,11 +1513,6 @@
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==

"@fastify/busboy@^2.0.0":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@fastify/busboy/-/busboy-2.1.1.tgz#b9da6a878a371829a0502c9b6c1c143ef6663f4d"
integrity sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==

"@gar/promisify@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
Expand Down Expand Up @@ -12922,12 +12917,10 @@ undici-types@~5.26.4:
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

undici@^5.0.0:
version "5.29.0"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.29.0.tgz#419595449ae3f2cdcba3580a2e8903399bd1f5a3"
integrity sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==
dependencies:
"@fastify/busboy" "^2.0.0"
undici@^7.16.0:
version "7.16.0"
resolved "https://registry.yarnpkg.com/undici/-/undici-7.16.0.tgz#cb2a1e957726d458b536e3f076bf51f066901c1a"
integrity sha512-QEg3HPMll0o3t2ourKwOeUAZ159Kn9mx5pnzHRQO8+Wixmh88YdZRiIwat0iNzNNXn0yoEtXJqFpyW7eM8BV7g==

unicode-canonical-property-names-ecmascript@^2.0.0:
version "2.0.0"
Expand Down