Skip to content

fix(extension): content.js's loadOpportunityBadge has no failure handling around chrome.runtime.sendMessage, unlike every other message call site #6189

Description

@JSONbored

Context

apps/loopover-miner-extension/content.js:42-54 (loadOpportunityBadge) calls await chrome.runtime.sendMessage(...) with no try/catch. Every other message/async-boundary call site in this extension handles failure explicitly: background.js:19-21 (.then(...).catch((error) => sendResponse({ ok: false, ... }))), options.js:78-94 (form submit wraps everything in try/catch), and options.js:99-113 (syncNow wraps its own sendMessage in try/catch). If sendMessage rejects — a real MV3 failure mode (service worker asleep/restarting, "Extension context invalidated") — it's an unhandled rejection: the badge <aside> stays in the DOM permanently hidden with zero user-visible feedback, unlike the graceful container.remove() this same function already uses for its other failure paths.

Requirements

  • Wrap the chrome.runtime.sendMessage(...) call in loadOpportunityBadge in a try/catch, and on failure, call the same container.remove() cleanup this function already uses for its other failure paths (don't invent a new failure UX).
  • Do not change background.js's or options.js's existing error handling — they're already correct.

Test Coverage Requirements

Match this extension's existing test conventions (test/*.test.ts); add a regression test simulating a rejected sendMessage and confirming the badge container is cleanly removed instead of causing an unhandled rejection.

Deliverables

  • loadOpportunityBadge handles a rejected sendMessage the same way it handles its other failure paths.
  • Regression test for this failure path.

Expected Outcome

A sendMessage failure in the content script no longer produces an unhandled rejection or a permanently-hidden orphan DOM element.

Links & Resources

  • apps/loopover-miner-extension/content.js:42-54
  • apps/loopover-miner-extension/background.js:19-21, options.js:78-94,99-113 (existing error-handling pattern to match)

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:bugGittensor-scored bug fix — scores a 0.05x multiplier.help wantedExtra attention is needed

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions