Skip to content

Commit 7aed56c

Browse files
committed
test(cloudflare): Unflake integration test
1 parent 7cb960b commit 7aed56c

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

dev-packages/cloudflare-integration-tests/runner.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ export function createRunner(...paths: string[]) {
237237
`SENTRY_DSN:http://public@localhost:${mockServerPort}/1337`,
238238
'--var',
239239
`SERVER_URL:${serverUrl}`,
240+
'--port',
241+
'0',
242+
'--inspector-port',
243+
'0',
240244
],
241245
{ stdio, signal },
242246
);

dev-packages/cloudflare-integration-tests/suites/tracing/durableobject-spans/test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,20 @@ it('sends child spans on repeated Durable Object calls', async ({ signal }) => {
4545
// Expect 5 transaction envelopes — one per call.
4646
const runner = createRunner(__dirname).expectN(5, assertDoWorkEnvelope).start(signal);
4747

48+
// Small delay between requests to allow waitUntil to process in wrangler dev.
49+
// This is needed because wrangler dev may not guarantee waitUntil completion
50+
// the same way production Cloudflare does. Without this delay, the last
51+
// envelope's HTTP request may not complete before the test moves on.
52+
const delay = () => new Promise(resolve => setTimeout(resolve, 50));
53+
4854
await runner.makeRequest('get', '/');
55+
await delay();
4956
await runner.makeRequest('get', '/');
57+
await delay();
5058
await runner.makeRequest('get', '/');
59+
await delay();
5160
await runner.makeRequest('get', '/');
61+
await delay();
5262
await runner.makeRequest('get', '/');
5363
await runner.completed();
5464
});

dev-packages/cloudflare-integration-tests/vite.config.mts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export default defineConfig({
2828
singleThread: true,
2929
},
3030
},
31+
sequence: {
32+
shuffle: true,
33+
},
3134
reporters: process.env.DEBUG
3235
? ['default', { summary: false }]
3336
: process.env.GITHUB_ACTIONS

0 commit comments

Comments
 (0)