Skip to content

Commit

Permalink
Fix App crashing when chrome runtime is unavailable (#8275)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymetz authored Apr 18, 2024
1 parent f73b84b commit d6f09f3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mv3/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import { type Tabs } from "webextension-polyfill";
import { once } from "lodash";

export const isMV3 = once(
(): boolean => chrome.runtime.getManifest().manifest_version === 3,
(): boolean =>
// Use optional chaining in case the chrome runtime is not available:
// https://github.com/pixiebrix/pixiebrix-extension/issues/8273
chrome.runtime?.getManifest().manifest_version === 3,
);
export const browserAction =
globalThis.chrome?.browserAction ?? globalThis.chrome?.action;
Expand Down

0 comments on commit d6f09f3

Please sign in to comment.