-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Labels
needs-triageThis ticket needs investigation.This ticket needs investigation.
Description
Problem
The following code runs perfectly on local network dfx start
but fails on mainnet:
const JWK_URL: &str =
"https://www.googleapis.com/service_accounts/v1/jwk/[email protected]";
pub async fn fetch_public_keys() -> Result<JwkKeys, FetchPublicKeysError> {
let response =
ic_cdk::management_canister::http_request(&ic_cdk::management_canister::HttpRequestArgs {
url: JWK_URL.to_string(),
max_response_bytes: None,
method: ic_cdk::management_canister::HttpMethod::GET,
headers: vec![],
body: None,
transform: None,
})
.await
.map_err(FetchPublicKeysError::CouldntFetchPublicKeys)?;
// ...
}
The error: No consensus could be reached. Replicas had different responses.
I'm almost certain that the reason for this error is that HTTP response is different for each call to this URL (max-age header value changes). There's no way for such errors to be caught in development
Potential solution
PocketIC should try to make more than one HTTP call and compare response results, to better simulate the production environment. Just two calls would've caught the error for the aforementioned URL
Metadata
Metadata
Assignees
Labels
needs-triageThis ticket needs investigation.This ticket needs investigation.