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

fix: don not log errors when onError is provided #162

Merged
merged 1 commit into from Aug 10, 2022
Merged

Conversation

danielroe
Copy link
Member

Currently we get two copies of error logs if we are logging them in a user-provided onError handler. Presumably it makes sense for user to log (or not) if they are providing their own error handler

@danielroe danielroe added the bug Something isn't working label Aug 10, 2022
@danielroe danielroe requested a review from pi0 August 10, 2022 13:58
@danielroe danielroe self-assigned this Aug 10, 2022
@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #162 (15379c7) into main (a8fa857) will increase coverage by 0.07%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #162      +/-   ##
==========================================
+ Coverage   65.40%   65.47%   +0.07%     
==========================================
  Files          14       14              
  Lines         922      921       -1     
  Branches      200      200              
==========================================
  Hits          603      603              
+ Misses        124      123       -1     
  Partials      195      195              
Impacted Files Coverage Δ
src/app.ts 68.20% <0.00%> (+0.39%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@pi0
Copy link
Member

pi0 commented Aug 10, 2022

This change makes sense but is slighly breaking. We need to update two places at least:

@danielroe
Copy link
Member Author

danielroe commented Aug 10, 2022

I don't think we need to update the framework code. That line is already logging the error to the console.

And I'm probably misunderstanding, but don't we already log in https://github.com/unjs/nitro/blob/e10f1307d765b0ac35e5492c14f804086569ac91/src/runtime/error.ts#L29-L31 ?

For example, see https://stackblitz.com/edit/github-p8e2d2?file=routes%2Findex.ts - you can see both h3 + nitro logs on the console.

@pi0
Copy link
Member

pi0 commented Aug 10, 2022

I missed nitro one but neither are handling .fatal flag (nuxt ignores it i guess even)

@danielroe
Copy link
Member Author

Good point! In that case it's not breaking, but just incremental improvement to suppressing logging for non-fatal, non-unhandled errors. I'll follow up with PRs to framework + nitro.

@pi0 pi0 changed the title fix: don't log error when user-provided error-handler fix: don not log errors when onError is provided Aug 10, 2022
@pi0 pi0 merged commit ccc9c7e into main Aug 10, 2022
@pi0 pi0 deleted the fix/duplicate-errors branch August 10, 2022 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants