Skip to content

fix: handle null registration.active in service worker registration#8213

Merged
mscolnick merged 2 commits intomarimo-team:mainfrom
AhmadYasser1:fix/service-worker-null-check
Feb 9, 2026
Merged

fix: handle null registration.active in service worker registration#8213
mscolnick merged 2 commits intomarimo-team:mainfrom
AhmadYasser1:fix/service-worker-null-check

Conversation

@AhmadYasser1
Copy link
Contributor

Summary

Guards against registration.active being null when registering the service worker, preventing a TypeError in browsers where the service worker hasn't activated yet.

Closes #8185

Test Plan

  • Added null check test for service worker registration
Service worker registration code assumes `registration.active` is
immediately available after calling `navigator.serviceWorker.register()`.
However, service workers go through lifecycle states (installing ->
waiting -> active), and `registration.active` can be `null` during
transitions, causing `TypeError: registration.active is null` errors
in the browser console.

This adds a `sendNotebookId` helper that:
- Checks if `registration.active` exists before posting the message
- Falls back to listening for `statechange` on the installing/waiting
  worker and posts the message once activated

Fixes marimo-team#5304
@mscolnick mscolnick requested a review from Copilot February 9, 2026 18:53
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@mscolnick mscolnick requested a review from Copilot February 9, 2026 18:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Feb 9, 2026 9:44pm

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mscolnick mscolnick merged commit c68a27a into marimo-team:main Feb 9, 2026
30 of 47 checks passed
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.10-dev20

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

Labels

bug Something isn't working

3 participants