Skip to content

Conversation

@benmccann
Copy link
Collaborator

@benmccann benmccann commented Jun 7, 2024

Description

fixes #17418

Ensure that we show an error if /@vite/client cannot be loaded. Prior to this PR the error handler worked only with post middlewares. Now it works with all middlewares

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@benmccann benmccann force-pushed the benmccann-patch-1 branch 4 times, most recently from 9cb1c1c to 609d437 Compare June 8, 2024 05:23
@benmccann benmccann modified the milestone: 5.3 Jun 8, 2024
@benmccann benmccann added the p3-minor-bug An edge case that only affects very specific usage (priority) label Jun 8, 2024
@bluwy
Copy link
Member

bluwy commented Jun 10, 2024

I feel we could improve the DX by having the error overlay support a "standalone" mode or "non-dismissable" mode? That way the error overlay is non-dismissable (as there's no reason so), and if they accidentally clicked outside, they won't get a lousier UI.

I also think we should only render the fallback error if the error overlay fail to load? We should also add an additional message that the error overlay failed to load.

@benmccann
Copy link
Collaborator Author

Those sound like reasonable ideas, but are all more complicated to implement and are just UX niceties. Maybe we could move ahead with this to fix the core issue of having a blank page and then file an issue for the followup ideas

@bluwy
Copy link
Member

bluwy commented Jun 10, 2024

I don't think the issue is urgent enough that we should go ahead with this middleground, since the error can be viewed from the terminal too? So I'm leaning on doing a proper fix instead 😬

@benmccann benmccann force-pushed the benmccann-patch-1 branch from 609d437 to 1f774b2 Compare June 11, 2024 00:00
@benmccann
Copy link
Collaborator Author

I also think we should only render the fallback error if the error overlay fail to load? We should also add an additional message that the error overlay failed to load.

I made both of these changes

I feel we could improve the DX by having the error overlay support a "standalone" mode or "non-dismissable" mode? That way the error overlay is non-dismissable (as there's no reason so), and if they accidentally clicked outside, they won't get a lousier UI.

This part really feels separate to me. The current PR is purely an improvement over the current state. In the cases where there previously was a blank page we're now showing an error and in the cases where the overlay was rendering it's exactly the same. I do like the idea of a non-dismissable mode, but think we could handle that in a separate PR

@bluwy
Copy link
Member

bluwy commented Jun 13, 2024

Thanks! Yeah fair we can handle that separately 👍

patak-dev
patak-dev previously approved these changes Jul 1, 2024
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should merge this one so the issue is fixed, and we can improve it later on

@bluwy
Copy link
Member

bluwy commented Jul 18, 2024

document.innerHTML = didn't work for me, I needed to use document.body.innerHTML. But anyways I used .appendChild directly since this would help with weird security stuff, and we don't have to concern of escaping much as we use .textContent. I also updated the view a bit. Now it looks like this:

image

I also tried inlining the overlay to prevent any requests, but that seemed tricky as we need it to go through the plugin pipeline (for any frameworks who want to edit it) and deal with constants that can only be replaced by the clientInjections plugin.

@benmccann
Copy link
Collaborator Author

Thank you @bluwy. I appreciate you taking the time to look at this and make additional improvements! The changes you made look good to me

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@patak-dev patak-dev merged commit db5ab1d into main Jul 18, 2024
@patak-dev patak-dev deleted the benmccann-patch-1 branch July 18, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p3-minor-bug An edge case that only affects very specific usage (priority)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error middleware cannot display errors from plugin middlewares

4 participants