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: error log improvements #1202

Merged
merged 8 commits into from Apr 28, 2022

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Apr 28, 2022

Closes: #1132, #884, #1201
Fixes: #1165, #1203

  • Errors show full stacktrace, since it's really hard to debug errors without an actual stacktrace (sometimes it has none, or look at Unhandled error when suite name is a function reference #1201)
  • Unhandled errors don't exit process, but fail the whole suite
  • Unhandled errors are shown after the summary with a warning
  • Clarified error message for "Vitest was initialized with Native Node"
  • If errors have custom properties, they are shown under "Serialized Error" - previously I wanted to show them like Node does, but it looks bad, if error has only one stack trace with a code frame, so I decided to split it
  • If error has "cause", print the case as the error without a code frame

@netlify
Copy link

netlify bot commented Apr 28, 2022

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 79793f1
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/626a65013928d30009237baa
😎 Deploy Preview https://deploy-preview-1202--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

if (s === nearest && nearest) {
const sourceCode = await fs.readFile(fileFromParsedStack(nearest), 'utf-8')
const sourceCode = readFileSync(fileFromParsedStack(nearest), 'utf-8')
Copy link
Member Author

Choose a reason for hiding this comment

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

I found a bug where fs.readFile stalls the terminal, and breaks for of loop - because of that some stack trace might be missing.

printError(err: unknown) {
return printError(err, this)
printError(err: unknown, fullStack = false) {
return printError(err, fullStack, this)
Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should show all stack trace for some errors (like unhandled ones), bacause it's really hard to debug otherwise.

@sheremet-va sheremet-va marked this pull request as draft April 28, 2022 08:11
@sheremet-va sheremet-va marked this pull request as ready for review April 28, 2022 09:34
toString on error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

throw from an async method, exits vitest watch Clarify Vitest was initialized with Native Node error
3 participants