You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{
"type": "TypeError",
"message": "RequestInit: duplex option is required when sending a body.",
"stack":
TypeError: RequestInit: duplex option is required when sending a body.
at new Request (node:internal/deps/undici/undici:7225:19)
at createNodeRequest (file:///___/node_modules/authey/dist/index.mjs:32:10)
at file:///___/node_modules/authey/dist/index.mjs:105:23
at Holder.done (___\node_modules\@fastify\middie\engine.js:112:11)
at Object.run (___\node_modules\@fastify\middie\engine.js:59:12)
at Object.runMiddie (file:///___/node_modules/fastify-next-auth/dist/index.mjs:21:12)
at hookIterator (___\node_modules\fastify\lib\hooks.js:293:10)
at next (___\node_modules\fastify\lib\hooks.js:185:16)
at handleResolve (___\node_modules\fastify\lib\hooks.js:196:5)
}
Adding duplex: 'half' between line 30 & 31 in src/fetch.ts fixes it.
Typescript 5.0.4 considers use of duplex as an error. The property duplex does not exist in type RequestInit as defined in typescript/lib/lib.dom.d.ts, but this is due to an omission on the type which is pointed out at microsoft/TypeScript-DOM-lib-generator#1483
This doesn't cause an error for GET and HEAD requests, since duplex only needs to be specified when there is a body in the request, so it could alternately be added around line 34:
if (req.method !== 'GET' && req.method !== 'HEAD'){
init.body = req as any
init.duplex = 'half';
}
Either way makes the resulting javascript functional, but both approaches run into the type checking error due to the incomplete type definition issue, bu
Judging by the conversation around an issue in node itself nodejs/node#46221 it sounds like the duplex option requirement is not likely to be reverted.
Related nodejs/node#46221
Adding
duplex: 'half'
between line 30 & 31 insrc/fetch.ts
fixes it.https://github.com/wobsoriano/authey/blob/main/src/fetch.ts#L24-L37
Running Node.js v18.16.0, fastify 4.16.3, fastify-next-auth 0.3.0
The text was updated successfully, but these errors were encountered: