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

Redirect inside server action throws an error #58002

Closed
1 task done
giladl82 opened this issue Nov 3, 2023 · 2 comments
Closed
1 task done

Redirect inside server action throws an error #58002

giladl82 opened this issue Nov 3, 2023 · 2 comments
Labels
examples Issue was opened via the examples template. locked

Comments

@giladl82
Copy link

giladl82 commented Nov 3, 2023

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
Binaries:
  Node: 18.16.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.0
  eslint-config-next: 14.0.0    
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which example does this report relate to?

Learn Next.js

What browser are you using? (if relevant)

Chrome

How are you deploying your application? (if relevant)

Vercel

Describe the Bug

Going over the next learn tutorials (https://nextjs.org/learn/dashboard-app/mutating-data)
I get the following error when trying to redirect within a server action

Error: NEXT_REDIRECT
at getRedirectError (webpack-internal:///(action-browser)/./node_modules/next/dist/client/components/redirect.js:44:19)
at redirect (webpack-internal:///(action-browser)/./node_modules/next/dist/client/components/redirect.js:54:11)
at createInvoice (webpack-internal:///(action-browser)/./app/lib/actions.ts:49:66)
at async C:\z_projects\nextjs-dashboard\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:38:479
at async tK (C:\z_projects\nextjs-dashboard\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:37:4768)
at async ri (C:\z_projects\nextjs-dashboard\node_modules\next\dist\compiled\next-server\app-page.runtime.dev.js:38:28770)
at async doRender (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:1340:26)
at async cacheEntry.responseCache.get.incrementalCache.incrementalCache (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:1500:28)
at async DevServer.renderToResponseWithComponentsImpl (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:1408:28)
at async DevServer.renderPageComponent (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:1760:24)
at async DevServer.renderToResponseImpl (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:1798:32)
at async DevServer.pipeImpl (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:851:25)
at async NextNodeServer.handleCatchallRenderRequest (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\next-server.js:266:17)
at async DevServer.handleRequestImpl (C:\z_projects\nextjs-dashboard\node_modules\next\dist\server\base-server.js:748:17) {
digest: 'NEXT_REDIRECT;replace;/dashboard/invoices;false',
mutableCookies: p {
_parsed: Map(2) { '__clerk_db_jwt' => [Object], '__client_uat' => [Object] },
_headers: HeadersList {
cookies: [Array],
[Symbol(headers map)]: [Map],
[Symbol(headers map sorted)]: null
}
}
}

Expected Behavior

I would expect the tutorial to be fixed

To Reproduce

As the tutorial describes

@giladl82 giladl82 added the examples Issue was opened via the examples template. label Nov 3, 2023
@giladl82
Copy link
Author

giladl82 commented Nov 3, 2023

After kept reading I got I needed to move the redirect outside of the try-catch.
My bad

@giladl82 giladl82 closed this as completed Nov 3, 2023
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
examples Issue was opened via the examples template. locked
Projects
None yet
Development

No branches or pull requests

1 participant