Skip to content

Commit c21fece

Browse files
authored
fix: reverts read_state polling expiry changes (#971)
1 parent 767ebcc commit c21fece

File tree

3 files changed

+2
-12
lines changed

3 files changed

+2
-12
lines changed

docs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Changed
1010

11+
- fix: reverts read_state polling expiry changes due to mismatched signature introduced in 2.1.3. Polling will re-use the original request as before, up to the point where the request expires
1112
- feat: HttpAgent uses anonymous identity to make syncTime call, which can allow readState calls to work beyond 5 minutes
1213
- chore: bumps .nvmrc and nodejs version in CI to 22
1314
- HttpAgent now awaits fetching rootkey before making network calls if `shouldFetchRootKey` is set

packages/agent/src/agent/http/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,13 +1062,7 @@ export class HttpAgent implements Agent {
10621062

10631063
const transformedRequest = request ?? (await this.createReadStateRequest(fields, identity));
10641064

1065-
// With read_state, we should always use a fresh expiry, even beyond the point where the initial request would have expired
1066-
const bodyWithAdjustedExpiry = {
1067-
...transformedRequest.body,
1068-
ingress_expiry: new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS),
1069-
};
1070-
1071-
const body = cbor.encode(bodyWithAdjustedExpiry);
1065+
const body = cbor.encode(transformedRequest.body);
10721066

10731067
this.log.print(
10741068
`fetching "/api/v2/canister/${canister}/read_state" with request:`,

packages/agent/src/polling/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ export async function pollForResponse(
8686
const path = [new TextEncoder().encode('request_status'), requestId];
8787
const currentRequest = request ?? (await agent.createReadStateRequest?.({ paths: [path] }));
8888

89-
// Use a fresh expiry for the repeated readState call
90-
if (request && isSignedReadStateRequestWithExpiry(currentRequest)) {
91-
currentRequest.body.content.ingress_expiry = new Expiry(DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS);
92-
}
93-
9489
const state = await agent.readState(canisterId, { paths: [path] }, undefined, currentRequest);
9590
if (agent.rootKey == null) throw new Error('Agent root key not initialized before polling');
9691
const cert = await Certificate.create({

0 commit comments

Comments
 (0)