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
TypeScript RequestInit interface missing 'duplex' #1769
Comments
node-fetch do kind of already support streams before duplex became spec'ed
|
Thanks for the quick response. When specifying the body as Blob.stream() to get the ReadableStream, I'm getting this error:
Not sure if I'm doing something wrong, but when adding the Since we are using typescript, we would like to have the |
Technically "half" functions as "full" right now in Node.js and Deno's implementation of No browser implements full-duplex using However, on Chromium-based browsers we can full-duplex stream between a We can use a browser extension to use Deno or Node.js implementation, for the capability to full-duplex stream to and from the server fom arbitrary Web pages, see https://github.com/guest271314/native-messaging-deno/tree/fetch-duplex, and https://github.com/guest271314/native-messaging-nodejs/tree/full-duplex. |
Hello, I encountered the same issue. |
Seems like an issue... node fetch RequestInit has a property |
TypeScript requires me to add the missing no TypeError: RequestInit: duplex option is required when sending a body.
at new Request (node:internal/deps/undici/undici:5499:19)
at R (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:340580)
at D (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:60308)
at /Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62407
at /Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/server/lib/trace/tracer.js:131:36
at NoopContextManager.with (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
at ContextAPI.with (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
at NoopTracer.startActiveSpan (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18093)
at ProxyTracer.startActiveSpan (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:18854)
at /Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/server/lib/trace/tracer.js:120:103
at NoopContextManager.with (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
at ContextAPI.with (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)
at NextTracerImpl.trace (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/server/lib/trace/tracer.js:120:28)
at globalThis.fetch (/Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:56863)
at MSGraphDriveProvider.uploadDriveItem (webpack-internal:///(rsc)/./src/lib/ms-graph/drive.ts:55:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PUT (webpack-internal:///(rsc)/./src/app/api/graph/upload/route.tsx:30:22)
at async /Users/hoarfroster/Desktop/hfrecipe/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:62609 having Type error: No overload matches this call.
Overload 1 of 2, '(input: string | URL | Request, init?: RequestInit): Promise<Response>', gave the following error.
Object literal may only specify known properties, and 'duplex' does not exist in type 'RequestInit'.
Overload 2 of 2, '(input: URL | RequestInfo, init?: RequestInit): Promise<Response>', gave the following error.
Object literal may only specify known properties, and 'duplex' does not exist in type 'RequestInit'.
89 | },
90 | body: content,
> 91 | duplex: 'half'
| ^
92 | }
93 | ).then(async (res) => {
94 | return (await res.json()) as MSGraphDriveItem | MSGraphError; |
Also getting this error. Does anyone have a resolution? |
same issue, any update? |
Posting the fix for my use case ... which was an API proxy using NextJS (but it may help others into looking into what they're sending in the body of the fetch call). The body in this case was a
then pass this as the body in the |
@agillespie-sp That's not streaming. We should be able to upload a |
passing the stream works, but only if you add |
Is there any way to solve this instead of using |
In WHATWG
RequestInit
hasRequestDuplex duplex
property but it's missing in node-fetch typescript APInode-fetch/@types/index.d.ts
Lines 71 to 112 in 8b3320d
Based on this https://fetch.spec.whatwg.org/#enumdef-requestduplex if fetch body is ReadableStream it requires the options
duplex
, want to check ifduplex
will be added to the RequestInit type in the new the near future, if not what is the process to contribute to adding a new type.Screenshots
https://fetch.spec.whatwg.org/#request-class
The text was updated successfully, but these errors were encountered: