Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: read state with fresh expiry #938

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

krpeacock
Copy link
Contributor

Description

With increased load events on some subnets, we have started to see cases where the read_state requests eventually start to have ingress_expiry errors after exceptionally long polling. Fortunately, the network allows us to have a separate ingress_expiry that differs from the one used in the request id during read_state requests.

This updates the expiry in polling and retry flows

Fixes # SDK-1855

How Has This Been Tested?

Using existing local and mainnet tests

Checklist:

  • My changes follow the guidelines in CONTRIBUTING.md.
  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

when polling for `read_state` requests. This prevents the request from exceeding the `maximum_ingress_expiry` when the replica is slow to respond.
@krpeacock krpeacock requested a review from a team as a code owner October 9, 2024 23:15
@krpeacock
Copy link
Contributor Author

cc @yvonneanne

Copy link
Contributor

github-actions bot commented Oct 9, 2024

size-limit report 📦

Path Size
@dfinity/agent 86.02 KB (-0.01% 🔽)
@dfinity/candid 13.58 KB (0%)
@dfinity/principal 4.97 KB (0%)
@dfinity/auth-client 60.36 KB (+0.01% 🔺)
@dfinity/assets 81.19 KB (+0.14% 🔺)
@dfinity/identity 57.56 KB (0%)
@dfinity/identity-secp256k1 131.32 KB (+0.08% 🔺)

@@ -14,6 +14,9 @@ export type PollStrategy = (
) => Promise<void>;
export type PollStrategyFactory = () => PollStrategy;

// Default delta for ingress expiry is 5 minutes.
const DEFAULT_INGRESS_EXPIRY_DELTA_IN_MSECS = 5 * 60 * 1000;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rust agent seems to use 3min. https://github.com/dfinity/agent-rs/blob/main/ic-agent/src/agent/agent_config.rs#L43

Do we wanna use 3min as the default in the agent-js as well?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, a constant with the same name and the same value already exists in agent/http/index.ts
https://github.com/dfinity/agent-js/pull/938/files#diff-1deee5c6f68eb82e2be634c32d050e818f857292ed0fa9c9e19026e2ef60869cR57

Copy link
Contributor Author

@krpeacock krpeacock Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Expiry class does additional rounding down, so it's closer to 4 minutes, generally. I would handle changing the default in a separate PR if we want to match agent-rs.

I can pull the constant out into a constants utility file, but I don't want to simply export it because that would put it into the @dfinity/agent library and it doesn't seem necessary

Copy link

@yvonneanne yvonneanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me, no need to squeeze in too many changes

Copy link

@yvonneanne yvonneanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, let's merge and roll this out asap to alleviate user pain :)

@krpeacock krpeacock enabled auto-merge (squash) October 15, 2024 23:27
@krpeacock krpeacock merged commit 00ad493 into main Oct 15, 2024
16 checks passed
@krpeacock krpeacock deleted the kai/SDK-1855-read-state-fresh-expiry branch October 15, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants