Skip to content

Commit 7edd803

Browse files
committed
skip test on node 18
1 parent bb07b62 commit 7edd803

1 file changed

Lines changed: 35 additions & 28 deletions

File tree

  • dev-packages/node-integration-tests/suites/tracing/fastify

dev-packages/node-integration-tests/suites/tracing/fastify/test.ts

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { afterAll, describe, expect } from 'vitest';
2+
import { conditionalTest } from '../../../utils';
23
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
34

45
describe('fastify auto-instrumentation', () => {
@@ -46,38 +47,44 @@ describe('fastify auto-instrumentation', () => {
4647
await runner.completed();
4748
});
4849

49-
test('captures errors thrown in route handlers', async () => {
50-
const runner = createRunner()
51-
.ignore('transaction')
52-
.expect({
53-
event: {
54-
exception: {
55-
values: [
56-
{
57-
type: 'Error',
58-
value: 'This is an exception with id 123',
59-
mechanism: {
60-
type: 'auto.function.fastify',
61-
handled: false,
50+
// Fastify v5 only publishes the `tracing:fastify.request.handler:error` diagnostics channel when
51+
// `tracingChannel(...).hasSubscribers` is truthy. That aggregate getter does not exist on Node 18
52+
// (it was added in Node 20), so fastify takes the fast path and never publishes the channel there —
53+
// making automatic error capture (without `setupFastifyErrorHandler`) impossible on Node 18.
54+
conditionalTest({ min: 20 })('error capture via diagnostics channel', () => {
55+
test('captures errors thrown in route handlers', async () => {
56+
const runner = createRunner()
57+
.ignore('transaction')
58+
.expect({
59+
event: {
60+
exception: {
61+
values: [
62+
{
63+
type: 'Error',
64+
value: 'This is an exception with id 123',
65+
mechanism: {
66+
type: 'auto.function.fastify',
67+
handled: false,
68+
},
6269
},
70+
],
71+
},
72+
transaction: 'GET /test-exception/:id',
73+
// The error must be parented to the fastify request span (not the root `http.server` span),
74+
// so the trace context carries a `parent_span_id`.
75+
contexts: {
76+
trace: {
77+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
78+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
79+
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
6380
},
64-
],
65-
},
66-
transaction: 'GET /test-exception/:id',
67-
// The error must be parented to the fastify request span (not the root `http.server` span),
68-
// so the trace context carries a `parent_span_id`.
69-
contexts: {
70-
trace: {
71-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
72-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
73-
parent_span_id: expect.stringMatching(/[a-f0-9]{16}/),
7481
},
7582
},
76-
},
77-
})
78-
.start();
79-
runner.makeRequest('get', '/test-exception/123', { expectError: true });
80-
await runner.completed();
83+
})
84+
.start();
85+
runner.makeRequest('get', '/test-exception/123', { expectError: true });
86+
await runner.completed();
87+
});
8188
});
8289

8390
test('propagates trace data to outgoing requests within a request handler', async () => {

0 commit comments

Comments
 (0)