Skip to content

Commit

Permalink
refactor(zome-call): set default timeout to 60 sec (#185)
Browse files Browse the repository at this point in the history
* refactor: set default timeout to 60 sec

* ci: cache cargo too

* docs: update changelog

* ci cache fixture 2 builds
  • Loading branch information
jost-s committed Apr 17, 2023
1 parent ba6485e commit ce1415c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,25 @@ jobs:
env:
cache-name: test-zome
with:
path: test/e2e/fixture/zomes/foo/target
path: |
.cargo
test/e2e/fixture/zomes/foo/target
test/e2e/fixture2/coordinator2/target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}

- name: Install nix packages
run: nix develop -c $SHELL -c "echo Nix packages installed"

- name: Install JS packages
run: nix develop -c $SHELL -c "npm ci"
- name: Build Nix packages
run: nix develop -c $SHELL -c "echo Nix packages built"

- name: Build test fixture
run: nix develop -c $SHELL -c "./build-fixture.sh"

- name: Install JS packages
run: nix develop -c $SHELL -c "npm ci"

- name: Run tests
run: nix develop -c $SHELL -c "npm t"

- name: Setup tmate session if a previous step failed
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 10
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Added
### Changed
- Set default timeout for API calls to 60 seconds.
### Fixed
### Removed

Expand Down
7 changes: 4 additions & 3 deletions src/api/app/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ export class AppWebsocket extends Emittery implements AppApi {
return appWebsocket;
}

_requester = <ReqI, ReqO, ResI, ResO>(
_requester<ReqI, ReqO, ResI, ResO>(
tag: string,
transformer?: Transformer<ReqI, ReqO, ResI, ResO>
) =>
requesterTransformer(
) {
return requesterTransformer(
(req, timeout) =>
promiseTimeout(
this.client.request(req),
Expand All @@ -107,6 +107,7 @@ export class AppWebsocket extends Emittery implements AppApi {
tag,
transformer
);
}

/**
* Request the app's info, including all cell infos.
Expand Down
2 changes: 1 addition & 1 deletion src/api/common.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { RoleName } from "../types.js";

const ERROR_TYPE = "error";
export const DEFAULT_TIMEOUT = 15000;
export const DEFAULT_TIMEOUT = 60000;

/**
* @public
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,27 @@ test("error is catchable when holochain socket is unavailable", async (t: Test)
}
});

test(
"zome call timeout can be overridden",
withConductor(ADMIN_PORT, async (t: Test) => {
const { client, admin, cell_id } = await installAppAndDna(ADMIN_PORT);
await admin.authorizeSigningCredentials(cell_id);
const zomeCallPayload: CallZomeRequest = {
cell_id,
zome_name: TEST_ZOME_NAME,
fn_name: "foo",
provenance: fakeAgentPubKey(),
payload: null,
};
try {
await client.callZome(zomeCallPayload, 1);
t.fail();
} catch (error) {
t.pass("zome call timed out");
}
})
);

test("can inject agents", async (t: Test) => {
const conductor1 = await launch(ADMIN_PORT);
const conductor2 = await launch(ADMIN_PORT_1);
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const installAppAndDna = async (
await admin.enableApp({ installed_app_id });
// destructure to get whatever open port was assigned to the interface
const { port: appPort } = await admin.attachAppInterface({ port: 0 });
const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, 12000);
const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`);
return { installed_app_id, cell_id, client, admin };
};

Expand Down

0 comments on commit ce1415c

Please sign in to comment.