From 382405b7e93190414987d4e60b3dcfb5c128231d Mon Sep 17 00:00:00 2001 From: Jost Schulte Date: Thu, 17 Oct 2024 19:49:36 -0600 Subject: [PATCH] fix(common): return request error without awaiting timeout --- src/api/common.ts | 1 + test/e2e/index.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/api/common.ts b/src/api/common.ts index 0e308c5e..7062034f 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -96,6 +96,7 @@ export const promiseTimeout = ( return res(a); }) .catch((e) => { + clearTimeout(id); return rej(e); }) ); diff --git a/test/e2e/index.ts b/test/e2e/index.ts index 4c176224..ba916bd4 100644 --- a/test/e2e/index.ts +++ b/test/e2e/index.ts @@ -425,7 +425,7 @@ test( test( "invalid app authentication token fails", withConductor(ADMIN_PORT, async (t) => { - const { admin, installed_app_id } = await installAppAndDna(ADMIN_PORT); + const { admin } = await installAppAndDna(ADMIN_PORT); const { port } = await admin.attachAppInterface({ allowed_origins: "client-test-app", }); @@ -1487,7 +1487,7 @@ test( }) ); -test( +test.only( "client fails to reconnect to websocket if closed before making a zome call if the provided token is invalid", withConductor(ADMIN_PORT, async (t) => { const { cell_id, client, admin } = await installAppAndDna(ADMIN_PORT); @@ -1504,7 +1504,9 @@ test( // Websocket is closed and app authentication token has expired. Websocket reconnection // should fail. try { - await client.callZome(callParams, 3000); + console.log("now calling"); + console.log(); + await client.callZome(callParams); t.fail( "reconnecting to websocket should have failed due to an invalid token." ); @@ -1520,7 +1522,7 @@ test( // Websocket reconnection has failed and subsequent calls should just return a websocket // closed error. try { - await client.callZome(callParams, 3000); + await client.callZome(callParams); t.fail("should not be attempted to reconnect websocket"); } catch (error) { t.assert(