Skip to content

Commit 1607304

Browse files
committed
try timeout sol
1 parent f70062a commit 1607304

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

dev-packages/node-integration-tests/suites/tracing/vercelai/scenario-express-error.mjs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,23 @@ async function run() {
6262
const server = createServer(app);
6363

6464
// Start server and make request
65-
server.listen(0, () => {
65+
server.listen(0, async () => {
6666
const port = server.address()?.port;
6767
// eslint-disable-next-line no-console
6868
console.log(JSON.stringify({ port }));
6969

70-
// Make the request that will trigger the error
71-
fetch(`http://localhost:${port}/api/chat`)
72-
.then(() => {
73-
server.close();
74-
})
75-
.catch(() => {
76-
server.close();
77-
});
70+
try {
71+
// Make the request that will trigger the error
72+
const response = await fetch(`http://localhost:${port}/api/chat`);
73+
await response.json(); // Consume the response
74+
} catch (error) {
75+
// Expected to fail due to the tool error, but we still want to capture it
76+
}
77+
78+
// Give time for Sentry to process and send the error
79+
setTimeout(() => {
80+
server.close();
81+
}, 1000);
7882
});
7983
}
8084

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ describe('Vercel AI integration', () => {
458458
expect(errorTraceId).toMatch(/^[a-f0-9]{32}$/);
459459

460460
expect(errorTraceId).toBe(transactionTraceId);
461-
});
461+
}, 30000);
462462
});
463463

464464
createEsmAndCjsTests(__dirname, 'scenario-express-error.mjs', 'instrument-with-pii.mjs', (createRunner, test) => {
@@ -504,6 +504,6 @@ describe('Vercel AI integration', () => {
504504
expect(errorTraceId).toMatch(/^[a-f0-9]{32}$/);
505505

506506
expect(errorTraceId).toBe(transactionTraceId);
507-
});
507+
}, 30000);
508508
});
509509
});

0 commit comments

Comments
 (0)