Adjust endpoint timeout failures (#9114)
This commit is contained in:
parent
80af84540c
commit
1bfd12d07e
@ -38,32 +38,8 @@ describe('check endpoints', (): void => {
|
|||||||
ws: value
|
ws: value
|
||||||
}))
|
}))
|
||||||
.filter((v): v is Endpoint => !!v.ws);
|
.filter((v): v is Endpoint => !!v.ws);
|
||||||
let completed = 0;
|
|
||||||
let errored = 0;
|
|
||||||
let websocket: WebSocket | null = null;
|
let websocket: WebSocket | null = null;
|
||||||
|
let closeTimerId: ReturnType<typeof setTimeout> | null = null;
|
||||||
afterEach((): void => {
|
|
||||||
completed++;
|
|
||||||
|
|
||||||
if (websocket) {
|
|
||||||
websocket.onclose = noopHandler;
|
|
||||||
websocket.onerror = noopHandler;
|
|
||||||
websocket.onopen = noopHandler;
|
|
||||||
websocket.onmessage = noopHandler;
|
|
||||||
|
|
||||||
try {
|
|
||||||
websocket.close();
|
|
||||||
} catch (e) {
|
|
||||||
console.error((e as Error).message);
|
|
||||||
}
|
|
||||||
|
|
||||||
websocket = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (completed === checks.length) {
|
|
||||||
process.exit(errored);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const { name, ws: endpoint } of checks) {
|
for (const { name, ws: endpoint } of checks) {
|
||||||
it(`${name} @ ${endpoint}`, async (): Promise<void> => {
|
it(`${name} @ ${endpoint}`, async (): Promise<void> => {
|
||||||
@ -102,13 +78,37 @@ describe('check endpoints', (): void => {
|
|||||||
reject(e);
|
reject(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
closeTimerId = setTimeout(
|
||||||
|
() => {
|
||||||
|
closeTimerId = null;
|
||||||
|
reject(new Error('Connection timeout'));
|
||||||
|
},
|
||||||
|
TIMEOUT
|
||||||
|
);
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.catch((e) => {
|
.finally(() => {
|
||||||
errored++;
|
if (closeTimerId) {
|
||||||
|
clearTimeout(closeTimerId);
|
||||||
|
closeTimerId = null;
|
||||||
|
}
|
||||||
|
|
||||||
throw e;
|
if (websocket) {
|
||||||
|
websocket.onclose = noopHandler;
|
||||||
|
websocket.onerror = noopHandler;
|
||||||
|
websocket.onopen = noopHandler;
|
||||||
|
websocket.onmessage = noopHandler;
|
||||||
|
|
||||||
|
try {
|
||||||
|
websocket.close();
|
||||||
|
} catch (e) {
|
||||||
|
console.error((e as Error).message);
|
||||||
|
}
|
||||||
|
|
||||||
|
websocket = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, TIMEOUT);
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user