Skip to content

Commit

Permalink
fix(common): return request error without awaiting timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jost-s committed Oct 18, 2024
1 parent b38aa5b commit 382405b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/api/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const promiseTimeout = (
return res(a);
})
.catch((e) => {
clearTimeout(id);
return rej(e);
})
);
Expand Down
10 changes: 6 additions & 4 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down Expand Up @@ -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);
Expand All @@ -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."
);
Expand All @@ -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(
Expand Down

0 comments on commit 382405b

Please sign in to comment.