-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(node): Use diagnostics channel for Fastify v5 error handling #16715
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
Conversation
size-limit report 📦
|
53d3aac
to
134bf84
Compare
} | ||
}); | ||
|
||
if (fastify.version?.startsWith('5.')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will break for > v5!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional, just in case Fastify v6 uses a different diagnostics channel hook for errors when published. It won't break if 6.x
is used here, in the worst scenario, the error will be captured twice, and deduped eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we check if our tracing:fastify.request.handler:error
diagnostics channel listener was registered, that feels like a more robust check.
I guess this is hard because others can also register on tracing:fastify.request.handler:error
. Perhaps we can do this by setting a field on the integration? Then you can grab the current client fastify integration instance and check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have just tried that. Looks like it's a bit tricky because dc.subscribe
does not return anything (we don't know if it subscribed or not at instrumentation time. If the hook is not found, it fails silently). We can set a flag in dc hook when an error happens, but the error handler plugin will be registered already, then we can maybe unregister it. Wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can set a flag in dc hook when an error happens, but the error handler plugin will be registered already, then we can maybe unregister it
yeah lets give this a try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! Need to think of how to document this best but this looks good.
Resolves: #15936