Skip to content
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

Remix is not compatible with updated fetch spec yet #6940

Closed
1 task done
MarkusWendorf opened this issue Jul 22, 2023 · 3 comments
Closed
1 task done

Remix is not compatible with updated fetch spec yet #6940

MarkusWendorf opened this issue Jul 22, 2023 · 3 comments
Assignees
Labels
bug:unverified feat:fetch Issues related to @remix-run/web-fetch

Comments

@MarkusWendorf
Copy link

What version of Remix are you using?

1.18.1

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Due to a recent change in the whatwg/fetch spec, the request constructor now requires the option duplex to be set when sending a body.

RequestInit: duplex option is required when sending a body
nodejs/node#46221

Remix currently fails when using the Node.js provided fetch implementation (undici). Right now this only happens when you do not install the Web API polyfills via installGlobals.

Example (without installGlobals, fastify adapter):
https://github.com/MarkusWendorf/remix-request-duplex/blob/main/server.mjs

Steps:

  1. npm run dev
  2. Go to /
  3. Type something in the input and submit
  4. you'll see an error

Expected Behavior

The form submission should work.

Remix should be compliant with the fetch spec. Right now nothing is really broken when using installGlobals, this is just a heads up.

Actual Behavior

TypeError: RequestInit: duplex option is required when sending a body.
    at new Request (node:internal/deps/undici/undici:7323:19)
    at stripIndexParam (/remix-fastify/example/node_modules/@remix-run/server-runtime/dist/data.js:87:10)
    at Object.callRouteActionRR (/remix-fastify/example/node_modules/@remix-run/server-runtime/dist/data.js:36:29)
    at handler (/remix-fastify/example/node_modules/@remix-run/server-runtime/dist/routes.js:59:50)
    at runHandler (/remix-fastify/example/node_modules/@remix-run/router/router.ts:3620:7)
    at callLoaderOrAction (/remix-fastify/example/node_modules/@remix-run/router/router.ts:3671:22)
    at submit (/remix-fastify/example/node_modules/@remix-run/router/router.ts:2829:22)
    at queryImpl (/remix-fastify/example/node_modules/@remix-run/router/router.ts:2764:28)
    at Object.queryRoute (/remix-fastify/example/node_modules/@remix-run/router/router.ts:2714:24)
    at handleDataRequestRR (/remix-fastify/example/node_modules/@remix-run/server-runtime/dist/server.js:75:40)
@brophdawg11 brophdawg11 added the feat:fetch Issues related to @remix-run/web-fetch label Jul 31, 2023
@brophdawg11 brophdawg11 added this to v2 Aug 3, 2023
@brophdawg11 brophdawg11 moved this to Backlog in v2 Aug 3, 2023
@jacob-ebey jacob-ebey moved this from Backlog to In progress in v2 Aug 15, 2023
@beerose
Copy link

beerose commented Aug 17, 2023

Hey @jacob-ebey and @brophdawg11!

What are your thoughts on using @whatwg-node/fetch in Remix? It's a ponyfill for the fetch standard, so it could solve this issue and maybe others related to fetch.

Of course, if you guys are already working on a better solution, just ignore my comment.

@jacob-ebey
Copy link
Member

jacob-ebey commented Aug 22, 2023

@MarkusWendorf applying similar changes found in this PR to the fastly adapter should address your issue: #7234

I'm closing for now as the adapter is not part of this projects codebase. I believe @mcansh owns the fastly adapter.

@jacob-ebey jacob-ebey moved this from In progress to PR in v2 Aug 22, 2023
@jacob-ebey jacob-ebey moved this from PR to Merged in v2 Aug 22, 2023
@mcansh
Copy link
Collaborator

mcansh commented Aug 24, 2023

fastify* - got a prerelease of it up under the pre tag on npm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:unverified feat:fetch Issues related to @remix-run/web-fetch
Projects
No open projects
Status: Merged
Development

No branches or pull requests

5 participants