-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Returning Response(null, { status: 404 })
from middleware makes astro dev
hang
#8257
Comments
Couldn't reproduce, the dev server continues to serve requests and handle module updates as expected. Could you check again? |
Stackblitz's example fails, too... Other than telling you that's the case, I have no idea how to test again, given it behaves like that to me (and even in the minimal example above). The page shows blank, while it should return the 404 page given what the middleware tells it to return. |
Is it possible that the middleware doesn't run? |
I doubt that, given that if I put anything else in there it works just as well. Even returning As I said above, putting the same in a page, not the middleware, works as expected when @natemoo-re suggested this solution on Discord. |
Adding that I am expecting to return the 404 page on a page that actually exists, so middleware should definitely run. |
404.astro wasn't there when I tested yesterday. I can confirm the issue now. |
Oh, I'm sure I added it... it might not have saved it and it did when I switched to that tab again after you posted. I think it's not just in dev, it's in prod, too, @lilnasy. |
Just tested by adding the node adapter to the repro, it works fine. |
I am going ahead and close the issue. This is a feature, and it requires some internal changes, which should also be reflected in the respective adapters. One of our maintainers - @lilnasy - created a proposal that would solve this issue: withastro/roadmap#681 If you need it, please upvote it! |
I'm not sure it is, it's a bug for me, if that's the way it's recommended to do 404 from middleware now.
Done! |
Astro info
What browser are you using?
Safari, Chrome
Describe the Bug
If I try and return
new Response(null, { status: 404 })
from the middleware (works in a page), the processastro dev
hangs indefinitely, forcing a manual restart.What's the expected result?
Returning the
404.astro
page.Link to Minimal Reproducible Example
https://stackblitz.com/edit/withastro-astro-issue-8257?file=src%2Fmiddleware.js
Participation
The text was updated successfully, but these errors were encountered: