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

feat(qwik): customize error overlay #2818

Merged
merged 12 commits into from
Mar 18, 2023

Conversation

zanettin
Copy link
Collaborator

@zanettin zanettin commented Feb 3, 2023

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests

Description

Qwikify the vite dev server error overlay. Fixes #2710.

Current Version

PR state after review session

B1

Terminal output (stays unaffected)

Bildschirmfoto 2023-02-04 um 20 44 05

Info

Todos

Follow-ups

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

@stackblitz
Copy link

stackblitz bot commented Feb 3, 2023

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

@@ -115,7 +115,8 @@
],
"devDependencies": {
"@builder.io/qwik-dom": "2.1.19",
"kleur": "4.1.5"
"kleur": "4.1.5",
"strip-ansi": "7.0.1"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

used on vite to strip the the frame output on the error overlay. since we have the code included atm, we need the lib as well

@@ -194,6 +194,9 @@ export function ssrDevMiddleware(ctx: BuildContext, server: ViteDevServer) {

next();
} catch (e) {
if (res.writableEnded) {
Copy link
Collaborator Author

@zanettin zanettin Feb 3, 2023

Choose a reason for hiding this comment

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

we've extended the qwik dev server middleware to handle errors as well instead of forwarding it to the vite error middleware. this because we are otherwise unable to ship the needed CSS to modify the overlay on SSR errors. The new error handler terminates the response with an .end() call. After that point it does no longer make sense to follow the next(e) path at all because an header already sent error would occur.

import { yellow, magenta, cyan } from 'kleur/colors';
import strip from 'strip-ansi';

/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i think about creating another PR on the vite repo to have an option to pass in some custom markdown into the vite error handler so we can remove the whole logic again on our side.

}

vite-error-overlay::part(tip):before {
content: "Not sure how to solve this? Visit https://qwik.builder.io or connect with the community on Discord.";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just an idea. please let me know what u think about it...

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah if this works! i think it's ok!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it does but w/o a link 😄 and can't style the url

@manucorporat
Copy link
Contributor

THIS IS AMAZING!! love it, this will deserve a good tweet when we merge it

@shairez
Copy link
Collaborator

shairez commented Feb 4, 2023

great job @zanettin !

Looks much more readable

BTW, for errors, I'd love to see the color "red" because it makes it easier to see that it's an error, immediately

Plus, not sure if it's possible, but syntax highlighting would also be great, but that's not a much

@manucorporat
Copy link
Contributor

I dont think code highlighting is an easy thing to add, i would not block this PR for that, we never had it before, but i would say, i would like to see the code with a more vibrant color, the yellow for vite was cooler.

@manucorporat
Copy link
Contributor

My only take would be to add a little bit of color, the red @shairez suggested would be nice and some other

@zanettin
Copy link
Collaborator Author

zanettin commented Feb 4, 2023

thanks a lot @manucorporat and @shairez for your feedbacks 🙏

the concern @shairez mentioned was about the terminal output which would stay unaffected by now.
i'll try to add some more colors to the overlay and post an update asap 🙏

regarding the formatting/highlighting: yes we are limited as long as we'd like to keep the vite error overlay web component since the error is rendered within a <pre> tag. if we would like to do everything on our side (other PR imo as well) we could do that which would give us complete flexibility 👍

@zanettin
Copy link
Collaborator Author

zanettin commented Feb 4, 2023

@manucorporat @shairez here are some other variations 👨‍🎨 😄
pls let me know in which direction i should go or if one of them match your expectations 🙏 i've also updated the description of the PR and added a screenshot of the terminal output.

B1

B1

B2

B2

B3

B3

C1

Bildschirmfoto 2023-02-04 um 21 26 55

@shairez
Copy link
Collaborator

shairez commented Feb 4, 2023

thanks @zanettin !

I prefer B2

@zanettin
Copy link
Collaborator Author

zanettin commented Feb 4, 2023

thanks @zanettin !

I prefer B2

thanks @shairez 🙏 maybe i should play around a bit with the aggressivity of the red color? give it a bit of opacity or so 👍
imo a bit less "qwik"-style than the other options but it is an error overlay after all 😄

@shairez
Copy link
Collaborator

shairez commented Feb 4, 2023

I think it's OK not to have the error message with the branded blue color, because it's an error after all :)

Maybe the icons could be with that blue or something, but it's not a biggie IMO

@zanettin
Copy link
Collaborator Author

zanettin commented Feb 4, 2023

totally with u @shairez 🙏 let me try some variations tomorrow evening 👍

@zanettin
Copy link
Collaborator Author

zanettin commented Feb 5, 2023

B4

Bildschirmfoto 2023-02-05 um 23 12 13
tiny adjusted B2 version (reduced red, removed blue completely from the screen)

@nnelgxorz
Copy link
Contributor

I think it looks great.

I personally prefer not having the error message header as red and reserving the red color for highlighting the actual error in the code, like this. Giant red text just makes me feel like I'm being yelled at.

I would bet that it stresses out beginners as well. Just my two cents. 👍

@shairez
Copy link
Collaborator

shairez commented Feb 6, 2023

but you ARE being yelled at @nnelgxorz !! 😅😂

@adamdbradley
Copy link
Contributor

Love it, and like the idea of less red and more qwik-ish colors. But think we ship it and see how it feels and iterate.

@zanettin
Copy link
Collaborator Author

zanettin commented Feb 6, 2023

thanks for all the feedbacks 🙏 set the current state of this PR to the B1 version. hope that is a good starting point. if you have other wishes/requirements, pls let me know 🙏
otherwise i'll wait till the PR on the vite repo got merged (was approved twice now 🎉 ) and we've upgraded to latest vite version for final testings.

@manucorporat
Copy link
Contributor

B1 is cool!

@zanettin zanettin added the COMP: DX Developer Experience related issue label Feb 15, 2023
@zanettin zanettin marked this pull request as ready for review March 17, 2023 22:00
@manucorporat manucorporat enabled auto-merge (squash) March 18, 2023 13:58
@manucorporat manucorporat merged commit bf9330f into QwikDev:main Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
COMP: DX Developer Experience related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[✨] Enhanced Error Overlay [DX]
5 participants