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

[🐛 Bug]: TypeError: This ReadableStream is disturbed (has already been read from) and cannot be used as a body. #920

Open
1 task
amorey opened this issue Dec 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@amorey
Copy link

amorey commented Dec 12, 2024

next-on-pages environment related information

System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:02:27 PDT 2024; root:xnu-11215.41.3~2/RELEASE_X86_64
CPU: (8) x64 Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
Memory: 32 GB
Shell: /bin/zsh
Package Manager Used: pnpm (9.14.2)

Relevant Packages:
@cloudflare/next-on-pages: 1.13.7
vercel: N/A
next: 15.0.3

Description

Using @edge-csrf/nextjs in middleware produces the error:

TypeError: This ReadableStream is disturbed (has already been read from) and cannot be used as a body.

Presumably this is because @edge-csrf/nextjs the parses the request body but it's still unexpected because the library only uses edge API methods to parse the request:
https://github.com/kubetail-org/edge-csrf/blob/main/shared/src/util.ts#L64-L122

I created a version of @edge-csrf/nextjs that clones the request before parsing it but I'm still getting the same error:
https://github.com/kubetail-org/edge-csrf/blob/2.5.3-cloudflare/packages/nextjs/src/index.ts#L66

Reproduction

This example project uses next@15 and @edge-csrf/[email protected]:
https://github.com/kubetail-org/edge-csrf/tree/2.5.3-cloudflare/examples/next15-cloudflare-pages

Pages Deployment Method

Direct Upload (wrangler pages publish or the @cloudflare/pages-action GitHub Action)

Pages Deployment ID

No response

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
@amorey amorey added the bug Something isn't working label Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant