Skip to content

Commit 0728ae2

Browse files
committed
Fix race in test causing flakyness
1 parent 40d6b52 commit 0728ae2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/test/src/test-nexus-handler.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,19 @@ test('operation handler cancelation', async (t) => {
166166
{
167167
method: 'POST',
168168
headers: {
169-
'Request-Timeout': '3s',
169+
'Request-Timeout': '2s',
170170
},
171171
}
172172
);
173173
t.is(res.status, 520 /* UPSTREAM_TIMEOUT */);
174+
// Give time for the worker to actually process the timeout; otherwise the operation
175+
// may end up being cancelled because of the worker shutdown rather than the timeout.
176+
await Promise.race([
177+
p?.catch(() => undefined),
178+
new Promise((resolve) => {
179+
setTimeout(resolve, 2000).unref();
180+
}),
181+
]);
174182
});
175183
t.truthy(p);
176184
await t.throwsAsync(p!, { instanceOf: CancelledFailure, message: 'TIMED_OUT' });

0 commit comments

Comments
 (0)