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

serveStatic swallows error codes meant for the client #40066

Closed
1 task done
lslunis opened this issue Aug 29, 2022 · 1 comment · Fixed by #40128
Closed
1 task done

serveStatic swallows error codes meant for the client #40066

lslunis opened this issue Aug 29, 2022 · 1 comment · Fixed by #40128
Labels
bug Issue was opened via the bug report template.

Comments

@lslunis
Copy link

lslunis commented Aug 29, 2022

Verify canary release

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

Provide environment information

n/a

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

serveStatic swallows nearly all status codes returned by send and just returns 500

In particular, it turns client errors like 416 Range Not Satisfiable into 500 errors.

Expected Behavior

4xx status codes should be passed through to the client.

Link to reproduction

n/a

To Reproduce

Run Next.js locally and curl any file in public/, eg favicon.ico:

curl -i -H 'Range: bytes=1000000000-' http://localhost:4000/favicon.ico
@lslunis lslunis added the bug Issue was opened via the bug report template. label Aug 29, 2022
SukkaW added a commit to SukkaW/next.js that referenced this issue Aug 31, 2022
SukkaW added a commit to SukkaW/next.js that referenced this issue Aug 31, 2022
SukkaW added a commit to SukkaW/next.js that referenced this issue Aug 31, 2022
@kodiakhq kodiakhq bot closed this as completed in #40128 Aug 31, 2022
kodiakhq bot pushed a commit that referenced this issue Aug 31, 2022
The PR fixes #40066.

Next.js' `serveStatic` method is powered by the [send](https://github.com/pillarjs/send) module, which could throw errors under specific circumstances.
Currently, Next.js only preserves the 412 Error from send, hence issue #40066 (where 416 Error is not preserved).

## Bug

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

github-actions bot commented Oct 1, 2022

This closed issue has been automatically locked because it had no new activity for a month. 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 Oct 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant