Sporadically missing values from chrome.runtime.getManifest or chrome namespace

107 views
Skip to first unread message

Tim Pillard

unread,
Aug 29, 2025, 11:03:02 AMAug 29
to Chromium Extensions
Hi,

Our Extension checks for some permissions in the manifest during its service worker critical initialization code path.
We have noticed in our reported exceptions something odd, it seems sometimes (up to a few hundred times per day) chrome.runtime.getManifest is either missing some keys or values, or the chrome namespace is missing properties.

Consider the following code which we use to determine whether or not we should use declarativeNetRequest (MV3) or WebRequest Blocking (MV2):

```ts
// manifest.json
// {
//   permissions: ['declarativeNetRequest']
// }

function isApiAvailable(path: string): boolean {
  if (typeof chrome === 'undefined') {
    return false;
  }
  const pathList = path.split('.');
  const api = pathList.reduce(
    (memo: any, subPath: string) => memo?.[subPath],
    chrome,
  );
  return Boolean(api);
}

function hasPermissions(requiredPermissions: string[]): boolean {
  const permissions = chrome.runtime.getManifest().permissions ?? [];
  return requiredPermissions.every((permission) =>
    permissions.includes(permission),
  );
}

// {...}
if (
    isApiAvailable('declarativeNetRequest') &&
    hasPermissions(['declarativeNetRequest'])
) {
  // This code path is not entered.
} else {
  // This code path is entered.
  // {...}
  console.log(getManifest().permissions);
  // ['declarativeNetRequest']
}
// {...}
```

Our Extension sees declarativeNetRequest as not supported and enters the WebRequest Blocking code path, which fails.

Is anyone seeing something similar?

Tim Pillard

unread,
Sep 19, 2025, 6:39:02 AM (7 days ago) Sep 19
to Chromium Extensions, Tim Pillard
What is likely to happen here is the declarativeNetRequest permission not being granted as part of enterprise deployment and not being reflected in the manifest's permissions.
Reply all
Reply to author
Forward
0 new messages