8000 Cloning a Request in edge runtime when running the dev server does not work correctly · Issue #57905 · vercel/next.js · GitHub
[go: up one dir, main page]

Skip to content

Cloning a Request in edge runtime when running the dev server does not work correctly #57905

New issue

Have a question about th 8000 is 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

Closed
1 task done
dkokotov opened this issue Nov 1, 2023 · 4 comments · May be fixed by vercel/edge-runtime#714 or vercel/edge-runtime#688
Closed
1 task done
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js. stale The issue has not seen recent activity.

Comments

@dkokotov
Copy link
dkokotov commented Nov 1, 2023

Link to the code that reproduces this issue

https://github.com/dkokotov/nextjs-edge-request-cloning-bug

To Reproduce

  1. Start the application in development
  2. Navigate to http://localhost:3000
  3. Observe that the method and headers of request 2 do not match those of request 1, even though request 2 was created by cloning request 1 (const req2 = new Request(req1))

Current vs. Expected behavior

Request 2 method and body should be the same as those of request 1.

Note this only happens for edge runtime. If, in the example below copied from the repro repository), I comment out the export const runtime = 'edge', the output is as expected.

export default function Home() {
  const req1 = new Request('https://example.com', {
    method: 'POST',
    headers: { 'X-Example-Header': 'Foo' }
  });
  const req2 = new Request(req1);

  return <div>
    Request 1 method: {req1.method}
    <br/>
    Request 1 headers: {req1.headers}
    <br/>
    Request 2 method: {req2.method}
    <br/>
    Request 2 headers: {req2.headers}
  </div>
}

export const runtime = 'edge';

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000
Binaries:
  Node: 20.8.0
  npm: 10.1.0
  Yarn: 1.22.19
  pnpm: 8.7.5
Relevant Packages:
  next: 14.0.2-canary.5
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, Middleware / Edge (API routes, runtime)

Additional context

Seems to only happen for running in dev mode. If I deploy the repro example to Vercel (https://nextjs-edge-request-cloning-bug.vercel.app), the output is as expected.

@dkokotov dkokotov added the bug Issue was opened via the bug report template. label Nov 1, 2023
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Nov 1, 2023
@remorses
Copy link
Contributor
remorses commented Nov 2, 2023

The bug lives here https://github.com/vercel/edge-runtime/blob/7a79df9fd22811cb9d73cfbaea9e76689a5b426c/packages/primitives/src/primitives/fetch.js#L18

addDuplexToInit Is doing …request which doesn’t work

@davidbarratt-drizly
Copy link

I think this should fix it? vercel/edge-runtime#714

@nextjs-bot
Copy link
Collaborator

This issue has been automatically marked as stale due to two years of inactivity. It will be closed in 7 days unless there’s further input. If you believe this issue is still relevant, please leave a comment or provide updated details. Thank you.

@nextjs-bot nextjs-bot added the stale The issue has not seen recent activity. label May 21, 2025
@nextjs-bot
Copy link
Collaborator

This issue has been automatically closed due to two years of inactivity. If you’re still experiencing a similar problem or have additional details to share, please open a new issue following our current issue template. Your updated report helps us investigate and address concerns more efficiently. Thank you for your understanding!

@nextjs-bot nextjs-bot closed this as not planned Won't fix, can't repro, duplicate, stale May 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Runtime Related to Node.js or Edge Runtime with Next.js. stale The issue has not seen recent activity.
Projects
None yet
4 participants
0