feat(node): Use diagnostics channel for Fastify v5 error handling#16715
feat(node): Use diagnostics channel for Fastify v5 error handling#16715AbhiPrasad merged 4 commits intodevelopfrom
Conversation
size-limit report 📦
|
53d3aac to
134bf84
Compare
| } | ||
| }); | ||
|
|
||
| if (fastify.version?.startsWith('5.')) { |
There was a problem hiding this comment.
This will break for > v5!
There was a problem hiding this comment.
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.
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.
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.
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
andreiborza
left a comment
There was a problem hiding this comment.
Nice work! Need to think of how to document this best but this looks good.
Resolves: #15936