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

The server crashes when getServerSideProps finishes executing #15118

Closed
rokinsky opened this issue Jul 13, 2020 · 8 comments · Fixed by #33366
Closed

The server crashes when getServerSideProps finishes executing #15118

rokinsky opened this issue Jul 13, 2020 · 8 comments · Fixed by #33366
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Milestone

Comments

@rokinsky
Copy link
Contributor

Bug report

Describe the bug

I'm trying to use next/link to refer to a route that uses getServerSideProps for redirection, and the server crashes when getServerSideProps finishes executing.

To Reproduce

Repository: next.js-bug-redirect
Steps to reproduce the behavior:

  1. Go to http://localhost:3000
  2. Click on Home link
  3. See error

Expected behavior

Redirecting back to /about.

Screenshots

Screenshot 2020-07-13 at 14 36 53

System information

  • OS: macOS
  • Browser (if applies): chrome
  • Version of Next.js: 9.4.4
  • Version of Node.js: 14.2.0

Additional context

Tried to run it with next@canary, but it also crashes.

@richyrb00
Copy link

Can you provide an example of how you are using Link in your project please?

@rokinsky
Copy link
Contributor Author

Can you provide an example of how you are using Link in your project please?

Here is the example next.js-bug-redirect/pages/about.js

@danawoodman
Copy link

Related to #14890 and #12409 I believe

@rokinsky
Copy link
Contributor Author

This issue still exists with 9.5.2.

@Timer Timer added this to the backlog milestone Sep 7, 2020
@timneutkens timneutkens added the Navigation Related to Next.js linking (e.g., <Link>) and navigation. label Nov 18, 2021
timneutkens added a commit to timneutkens/next.js that referenced this issue Jan 10, 2022
Adds a minimal reproduction for vercel#15118 as a test. The behavior is different in the latest version, it no longer crashes the server. The request hangs instead.
@timneutkens
Copy link
Member

Had a look at this and it's no longer crashing the server, however it does hang the particular request and does not resolve so this should still be investigated. I've added a minimal reproduction in #33129.

@timneutkens
Copy link
Member

@rokinsky it seems that the particular repository referenced has been removed or is marked private, could you check #33129 is that is the right reproduction code? I wrote it based on the issue description.

@rokinsky
Copy link
Contributor Author

@timneutkens sorry, I've removed all repositories related to the next.js bugs.

Your reproduction code seems correct except commented writeHead and end calls. This code throws an error with next.js 9.4.4 and nodes 14 and 16 as pointed out in the description issue. However, you are right, with next.js 12.0.7 such redirection just doesn't apply.

P.S. Despite all, if anyone else comes across this problem then it is highly recommended to use a more idiomatic redirect value that works correctly with the newest next.js versions.

@kodiakhq kodiakhq bot closed this as completed in #33366 Jan 16, 2022
kodiakhq bot pushed a commit that referenced this issue Jan 16, 2022
This fixes the case where calling `res.end()` is `getServerSideProps` would cause the request to hang in development due to our `Proxy` around `res` causing internal `ServerResponse` fields to not be available ([related post](https://javascript.info/proxy#built-in-objects-internal-slots)). I also migrated our `getServerSideProps` test suite to an e2e suite with a test for this case. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: #15118
Fixes: #32824
Closes: #33129
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Feb 16, 2022
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
This fixes the case where calling `res.end()` is `getServerSideProps` would cause the request to hang in development due to our `Proxy` around `res` causing internal `ServerResponse` fields to not be available ([related post](https://javascript.info/proxy#built-in-objects-internal-slots)). I also migrated our `getServerSideProps` test suite to an e2e suite with a test for this case. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: vercel#15118
Fixes: vercel#32824
Closes: vercel#33129
nevilm-lt pushed a commit to nevilm-lt/next.js that referenced this issue Apr 22, 2022
This fixes the case where calling `res.end()` is `getServerSideProps` would cause the request to hang in development due to our `Proxy` around `res` causing internal `ServerResponse` fields to not be available ([related post](https://javascript.info/proxy#built-in-objects-internal-slots)). I also migrated our `getServerSideProps` test suite to an e2e suite with a test for this case. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: vercel#15118
Fixes: vercel#32824
Closes: vercel#33129
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Navigation Related to Next.js linking (e.g., <Link>) and navigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants