From 2056146c951891a082d8e55d5c4d66212673462f Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 27 Feb 2020 08:27:48 -0800 Subject: [PATCH] Fix flaky timeout test in TS client (#19389) --- .../clients/ts/FunctionalTests/ts/HubConnectionTests.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts b/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts index 61b43e0654..93275f5336 100644 --- a/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts +++ b/src/SignalR/clients/ts/FunctionalTests/ts/HubConnectionTests.ts @@ -679,7 +679,6 @@ describe("hubConnection", () => { if (transportType !== HttpTransportType.LongPolling) { it("terminates if no messages received within timeout interval", async (done) => { const hubConnection = getConnectionBuilder(transportType).build(); - hubConnection.serverTimeoutInMilliseconds = 100; hubConnection.onclose((error) => { expect(error).toEqual(new Error("Server timeout elapsed without receiving a message from the server.")); @@ -687,6 +686,12 @@ describe("hubConnection", () => { }); 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", ""); }); }