Skip to content

docs(adev): reset webcontainer counter after OOM warning dismissal#67676

Open
tianxingleo wants to merge 2 commits intoangular:mainfrom
tianxingleo:fix/adev-webcontainer-counter-reset
Open

docs(adev): reset webcontainer counter after OOM warning dismissal#67676
tianxingleo wants to merge 2 commits intoangular:mainfrom
tianxingleo:fix/adev-webcontainer-counter-reset

Conversation

@tianxingleo
Copy link

@tianxingleo tianxingleo commented Mar 13, 2026

Summary

This PR fixes #52647 in the docs embedded editor.

When Safari reloads a tab after OOM, beforeunload may not fire, so numberOfWebcontainers can stay stale in localStorage. That can cause the OOM warning to appear even when the user has fewer than the recommended number of tabs open.

This change resets the webcontainer instances counter when the user dismisses the OOM warning (I understand).

Changes

  • subscribe to the OOM snackbar action in AlertManager
  • reset numberOfWebcontainers to 0 on dismissal
  • add AlertManager unit tests for increment/decrement/reset behavior

Testing

  • Added alert-manager.service.spec.ts coverage for:
    • increment on init
    • decrement on beforeunload
    • reset on OOM warning dismissal

Note: I could not run Bazel tests in this environment because bazelisk is not installed locally.

@pullapprove pullapprove bot requested a review from josephperrott March 13, 2026 07:20
@google-cla
Copy link

google-cla bot commented Mar 13, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

Can you please collapse the two commits into one.

We do not need a separate test scoped commit for creating the test, we can include the test in the fix commit.

}

private resetInstancesCounter(): void {
this.localStorage?.setItem(WEBCONTAINERS_COUNTER_KEY, '0');
Copy link
Member

Choose a reason for hiding this comment

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

Resetting the counters should reset to 1 since the currently running instance is active.

Suggested change
this.localStorage?.setItem(WEBCONTAINERS_COUNTER_KEY, '0');
this.localStorage?.setItem(WEBCONTAINERS_COUNTER_KEY, '1');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: counter of running webcontainer is not decreased when browser crashed due to OOM

3 participants