Skip to content

Commit c7437c6

Browse files
authored
fix(ic-certified-assets): set the ic_env cookie only if the canister environment changed (#4446)
# Description Sets the `ic_env` cookie for all HTML files only if the canister environment changed in the `commit_batch` method. The feature was first introduced in #4387. # How Has This Been Tested? Successfully deployed the [dfinity/portal](https://github.com/dfinity/portal) locally.
1 parent 9d53322 commit c7437c6

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
# UNRELEASED
44

5+
### Frontend canister
6+
7+
Sets the `ic_env` cookie for all HTML files only if the canister environment changed in the `commit_batch` method.
8+
9+
- Module hash: c156183e6a6f5c3c71ecde5f38a7280b770ff172b4827127ef03b89b764065ba
10+
- https://github.com/dfinity/sdk/pull/4446
11+
512
# 0.30.2
613

714
### Improve frontend canister sync logic

src/canisters/frontend/ic-certified-assets/src/state_machine/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,7 @@ impl State {
732732
system_context: &SystemContext,
733733
) -> Result<(), String> {
734734
// Reload the canister env to get the latest values
735+
let old_encoded_canister_env = self.encoded_canister_env.clone();
735736
self.encoded_canister_env = system_context.get_canister_env().to_cookie_value();
736737

737738
let (chunks_added, bytes_added) = self.compute_last_chunk_data(&arg);
@@ -753,7 +754,12 @@ impl State {
753754
self.batches.remove(&batch_id);
754755
self.certify_404_if_required();
755756

756-
self.update_ic_env_cookie_in_html_files();
757+
// Only re-certify all HTML files if the canister environment changed.
758+
// Assets modified in this batch already have the correct cookie via on_asset_change.
759+
// Note: this can cause the canister to incur in the instructions limit with many assets.
760+
if old_encoded_canister_env != self.encoded_canister_env {
761+
self.update_ic_env_cookie_in_html_files();
762+
}
757763
self.last_state_update_timestamp_ns = system_context.current_timestamp_ns;
758764

759765
Ok(())
-17 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)