Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Handle unhandledrejections in the dev server #9424
Handle unhandledrejections in the dev server #9424
Changes from 2 commits
da46bc1
2d9b88e
a550e92
8693171
46222e9
9b9f51b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit of a edge case, but presumably this should pass through our normal-ish error pipeline so we get a nicely formatted error.
astro/packages/astro/src/core/messages.ts
Line 257 in f8b27b0
How does this look in the browser too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can't pass through the normal error pipeline, it happens outside of the context of a request. You could do:
setTimeout(() => Promise.reject('foo'), 5000)
and there is no ongoing request, the rejection still happens.It doesn't currently show up in the browser, do we have a way to send an error from the server to the client outside of a request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that from where you are in the code, you'd be able to send to the websocket since you're so close to the server creation, here's how it works in the rendering:
astro/packages/astro/src/vite-plugin-astro-server/response.ts
Line 32 in f8b27b0
You should just need to send the error payload through the websocket and it should work!»
If you can't make it go through the entire pipeline, at least formatting the error message would be great:
astro/packages/astro/src/core/messages.ts
Line 257 in f8b27b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking to see if async_hooks can help. https://nodejs.org/api/async_hooks.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think AsyncLocalStorage can maybe allow this, going to give that try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And so it begins... I have many ideas for AsyncLocalStorage!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR and it should work now. Updated with a screenshot of what the browser receives. Would appreciate another review @Princesseuh