Skip to content

Expose the actual background error message in the options page #9767

Open

Description

@fregante

use the global error listener in the background page and then store the caught message via chrome.session so that it can be shown in the options page.

Originally posted by @fregante in #9766

Tasks:

  1. add background-loader.js entry point to manifest.json, this should be a plain js file outside the build
  2. add 'error' listener to it + store the error(s) in chrome.session

Requirements:

  • remove the listener (last line of background.ts) after the background page loaded successfully
  • verify that it actually works by adding throw new Error somewhere on the page

Note that only synchronous errors matter here. Errors happening in async functions do not break the background worker and it remains active.

Follows:

Activity

  1. added
    meta
    small
    on Jul 1, 2026
  2. changed the title [-]Expose background load failure error to options[/-] [+]Expose the actual background error message in the options page[/+] on Jul 1, 2026
  3. fregante commented on Jul 4, 2026

    @fregante
    MemberAuthor

    This appears to be impossible in service workers for many reasons:

    • import() not available, so no try/catch around it
    • errors cannot be preventDefault, so once it fails the service worker is unloaded
    • localStorage is not available in SW, so the SW fails before chrome.storage.session can save the error, assuming the global error handler is even called

    It can be done via chrome.actions.setBadge because I did it for one client, but that involved webpack in order to make import() work.

    So further exploration is needed but #9776 is a starting point

  4. removed
    small
    on Jul 4, 2026
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

    acceptedmeta

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions