Skip to content

Guard background messaging and detect startup paths#290

Open
geauxtigers wants to merge 1 commit intosimov:mainfrom
geauxtigers:fix/background-message-and-detect-guards
Open

Guard background messaging and detect startup paths#290
geauxtigers wants to merge 1 commit intosimov:mainfrom
geauxtigers:fix/background-message-and-detect-guards

Conversation

@geauxtigers
Copy link
Copy Markdown

Summary

This PR adds two defensive guards in the background scripts:

  • avoid messaging errors when there is no active content-script receiver
  • avoid startup-time detect errors before origin state is initialized

Changes

  • in background/messages.js, notifyContent() now:
    • returns early when there is no active tab
    • ignores chrome.runtime.lastError when a tab has no receiving content script
  • in background/detect.js, detect() now returns early when the URL or state.origins is not yet available

Why

While testing locally, the extension could emit background errors in normal browsing cases:

  • "Could not establish connection. Receiving end does not exist."
  • errors caused by reading state.origins before initialization completed

These guards make those paths no-op safely instead of surfacing runtime noise.

Scope

This PR intentionally does not include the copy-button feature work.

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.

1 participant