Skip to content

Conversation

@mjfaga
Copy link
Contributor

@mjfaga mjfaga commented Jan 15, 2026

Overview

When a browser extension context is fully invalidated (e.g., during extension update, reload, or disable), the browser.runtime object itself can become undefined, not just browser.runtime.id. This causes a runtime error when the isInvalid getter tries to access browser.runtime.id.

This change adds optional chaining to safely handle the case where browser.runtime is undefined, preventing the error and allowing the content script to properly detect and handle context invalidation.

Manual Testing

Added automated tests for this scenario.

Related Issue

#1676

This PR closes #1676

When a browser extension context is fully invalidated (e.g., during
extension update, reload, or disable), the `browser.runtime` object
itself can become `undefined`, not just `browser.runtime.id`. This
causes a runtime error when the `isInvalid` getter tries to access
`browser.runtime.id`.

This change adds optional chaining to safely handle the case where
`browser.runtime` is undefined, preventing the error and allowing
the content script to properly detect and handle context invalidation.
@netlify
Copy link

netlify bot commented Jan 15, 2026

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 4e3a610
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/69693184503d9d0008314a42
😎 Deploy Preview https://deploy-preview-2042--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

console will continue print Uncaught TypeError when extension update

1 participant