Skip to content

Commit dcbeae5

Browse files
committed
test(e2e): fix flaky async fallback readiness waits on CI
1 parent 6d582f2 commit dcbeae5

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

test/e2e/hooks.test.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,9 @@ describe('Hooks E2E Tests', () => {
644644
},
645645
} as Parameters<typeof Bun.serve>[0])
646646

647-
// Wait for the failing server to be ready
647+
// Wait for the failing server to be ready (allow extra time for slow CI runners)
648648
let failingServerReady = false
649-
for (let i = 0; i < 20; i++) {
649+
for (let i = 0; i < 100; i++) {
650650
try {
651651
const healthCheck = await fetch(`http://localhost:${asyncFailingPort}/`)
652652
if (healthCheck.status === 200) {
@@ -675,7 +675,7 @@ describe('Hooks E2E Tests', () => {
675675
const asyncRouteConfig: RouteConfig = {
676676
pattern: '/api/async-fallback/*',
677677
target: `http://localhost:${asyncFailingPort}`,
678-
timeout: 1000,
678+
timeout: 5000,
679679
proxy: {
680680
pathRewrite: {
681681
'^/api/async-fallback': '',
@@ -686,7 +686,7 @@ describe('Hooks E2E Tests', () => {
686686
asyncErrorCalls.push({ req, error })
687687

688688
// Simulate async operation (e.g., logging, fetching from cache, etc.)
689-
await new Promise((resolve) => setTimeout(resolve, 50))
689+
await new Promise((resolve) => setTimeout(resolve, 10))
690690

691691
// Generate dynamic fallback based on the request
692692
const url = new URL(req.url)
@@ -712,12 +712,9 @@ describe('Hooks E2E Tests', () => {
712712
asyncGateway.addRoute(asyncRouteConfig)
713713
const asyncServer = await asyncGateway.listen(asyncGatewayPort)
714714

715-
// Wait for the gateway server to be ready
716-
await new Promise((resolve) => setTimeout(resolve, 1000))
717-
718715
// Wait for the gateway server to be ready with proper health check
719716
let gatewayReady = false
720-
for (let i = 0; i < 20; i++) {
717+
for (let i = 0; i < 100; i++) {
721718
try {
722719
const healthCheck = await fetch(
723720
`http://localhost:${asyncGatewayPort}/api/async-fallback/`,

0 commit comments

Comments
 (0)