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: auto capture errors with nitroApp.captureError #1463

Merged
merged 11 commits into from
Jul 19, 2023
Merged

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Jul 19, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR allows capturing errors both automatically (for all requests + plugins + cache operations + node unhandled errors) and also manually using useNitroApp().captureError(error, { event, tags? }) and event.captureError(error, { tags? }) APIs.

It can be used to make a nitro plugin with integrations to external logging systems or custom log handling using new error hook (useNitroApp().hooks.hook('error', (error, context) => {}).

Async hooks will run in parallel and background for performance and also be captured using event.waitUntil to prevent timeouts on worker environments.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Merging #1463 (e7aeb73) into main (dd14c23) will increase coverage by 0.06%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1463      +/-   ##
==========================================
+ Coverage   76.14%   76.21%   +0.06%     
==========================================
  Files          73       73              
  Lines        7428     7433       +5     
  Branches      728      728              
==========================================
+ Hits         5656     5665       +9     
+ Misses       1771     1767       -4     
  Partials        1        1              
Impacted Files Coverage Ξ”
src/types/h3.ts 100.00% <100.00%> (ΓΈ)

... and 1 file with indirect coverage changes

@pi0 pi0 merged commit 454a920 into main Jul 19, 2023
6 checks passed
@pi0 pi0 deleted the feat/runtime-error branch July 19, 2023 13:15
@pi0 pi0 mentioned this pull request Aug 4, 2023
@DrJume DrJume mentioned this pull request Aug 30, 2023
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.

2 participants