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

Creating a new Response with a Status Code of 404 leads to an infinite loop when the /404.astro page is absent. #10581

Closed
1 task
gitcaduff opened this issue Mar 27, 2024 · 1 comment · Fixed by #10582
Assignees
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: error pages Related to 404 and 500 handling (scope) regression

Comments

@gitcaduff
Copy link

Astro Info

Astro                    v4.5.6
Node                     v20.5.1
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node
Integrations             @astrojs/svelte
                         @astrojs/tailwind

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

In the past it was feasible to generate Responses bearing the 404 status code. However, in the current setup (version 4.5.x and above), this process triggers an infinite loop due to Astro's subsequent search for the missing /404.astro page. To circumvent this loop, I opt not to furnish a /404.astro page. This choice stems from my desire to refrain from redirecting users to a dedicated 404 page. Instead, I intend to furnish a 404 Code directly while retaining the requested URL's context.

The problem exists only in dev mode and was already reported and fixed here: #8100
But with the new version 4.5.x the bug came back.

What's the expected result?

I would expect an Response with the status code 404 without redirecting to the missing /404.astro

return new Response("custom 404 html content", { status: 404 });

Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-jcjvxf?file=response-with-404-code%2Fsrc%2Fpages%2F[...path].astro

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Mar 27, 2024
@lilnasy lilnasy added - P4: important Violate documented behavior or significantly impacts performance (priority) feat: error pages Related to 404 and 500 handling (scope) regression and removed needs triage Issue needs to be triaged labels Mar 27, 2024
@lilnasy
Copy link
Contributor

lilnasy commented Mar 27, 2024

Thanks for the clean reproduction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) feat: error pages Related to 404 and 500 handling (scope) regression
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants