vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.9k stars 26.87k forks source link

Error Connection Closed on Redirect #58515

Open brizzbuzz opened 11 months ago

brizzbuzz commented 11 months ago

Link to the code that reproduces this issue

https://github.com/unredundant/nextjs-crash-on-redirect

To Reproduce

  1. Start the server in dev mode
  2. Go to port 3000 (or, whichever port the web app binds to)
  3. Enter the form info (any placeholder email and password will do)
  4. Feast you eyes on the glorious crash
  5. a reload with cmd r will load the dashboard page as expected, showing the page actually exists.

Confirmed on both pop_os 22.04 and macos whatever they called it (latest)

Current vs. Expected behavior

I should be able to redirect my web app to another page.

CleanShot 2023-11-15 at 18 54 07

Verify 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.5.1
  npm: 9.8.0
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 13.5.6
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

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

Not sure

Additional context

web:dev:  ⨯ Error: Connection closed.
web:dev:     at tu (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next/dist/compiled/next-se
rver/app-page.runtime.dev.js:35:303532)
web:dev:     at t.decodeReply (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next/dist/compi
led/next-server/app-page.runtime.dev.js:35:304915)
web:dev:     at /Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next/dist/compiled/next-server
/app-page.runtime.dev.js:38:264
web:dev:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
web:dev:     at async tX (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next/dist/compiled/n
ext-server/app-page.runtime.dev.js:37:5207)
web:dev:     at async rl (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next/dist/compiled/n
ext-server/app-page.runtime.dev.js:38:22994)
web:dev:     at async doRender (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next/dist/serv
er/base-server.js:1407:30)
web:dev:     at async cacheEntry.responseCache.get.routeKind (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/w
eb/node_modules/next/dist/server/base-server.js:1571:28)
web:dev:     at async DevServer.renderToResponseWithComponentsImpl (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/
apps/web/node_modules/next/dist/server/base-server.js:1479:28)
web:dev:     at async DevServer.renderPageComponent (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_m
odules/next/dist/server/base-server.js:1850:24)
web:dev:     at async DevServer.renderToResponseImpl (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_
modules/next/dist/server/base-server.js:1888:32)
web:dev:     at async DevServer.pipeImpl (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_modules/next
/dist/server/base-server.js:902:25)
web:dev:     at async NextNodeServer.handleCatchallRenderRequest (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/ap
ps/web/node_modules/next/dist/server/next-server.js:266:17)
web:dev:     at async DevServer.handleRequestImpl (/Users/megame/Workspace/unredundant/nextjs-crash-on-redirect/apps/web/node_mod
ules/next/dist/server/base-server.js:798:17) {
web:dev:   page: '/dashboard'
web:dev: }
HarrisonPortwood commented 10 months ago

@unredundant

A workaround to this would be: return Response.redirect(${request.nextUrl.origin}/dashboard);

Check out this comment made by another user for more info

MihinMUD commented 4 months ago

The workaround doesn't work for me because I'm on a server action. The error doesn't appear on dev but only on production build.

0x006E commented 3 months ago

Same issue. @MihinMUD Did you find any solutions for this?

Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!

blackmo18 commented 1 week ago

any updated on this? i experienced same behavior for latest 14.2.10