Fix flaky timeout test in TS client (#19389)
This commit is contained in:
parent
5b7672c2ad
commit
2056146c95
|
|
@ -679,7 +679,6 @@ describe("hubConnection", () => {
|
||||||
if (transportType !== HttpTransportType.LongPolling) {
|
if (transportType !== HttpTransportType.LongPolling) {
|
||||||
it("terminates if no messages received within timeout interval", async (done) => {
|
it("terminates if no messages received within timeout interval", async (done) => {
|
||||||
const hubConnection = getConnectionBuilder(transportType).build();
|
const hubConnection = getConnectionBuilder(transportType).build();
|
||||||
hubConnection.serverTimeoutInMilliseconds = 100;
|
|
||||||
|
|
||||||
hubConnection.onclose((error) => {
|
hubConnection.onclose((error) => {
|
||||||
expect(error).toEqual(new Error("Server timeout elapsed without receiving a message from the server."));
|
expect(error).toEqual(new Error("Server timeout elapsed without receiving a message from the server."));
|
||||||
|
|
@ -687,6 +686,12 @@ describe("hubConnection", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await hubConnection.start();
|
await hubConnection.start();
|
||||||
|
|
||||||
|
// set this after start completes to avoid network issues with the handshake taking over 100ms and causing a failure
|
||||||
|
hubConnection.serverTimeoutInMilliseconds = 1;
|
||||||
|
|
||||||
|
// invoke a method with a response to reset the timeout using the new value
|
||||||
|
await hubConnection.invoke("Echo", "");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue