Skip to content

Commit 0878319

Browse files
Fix window.atob references under Node
1 parent 136da6a commit 0878319

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/third_party/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ import {
5757
generateReport as generateReportImpl,
5858
} from './lighthouse-devtools-mcp-bundle.js';
5959

60+
// Some vendored DevTools/Lighthouse code paths call window.atob/window.btoa even
61+
// when running under Node.js. Expose a browser-like alias so those runtime calls
62+
// resolve to Node's global atob/btoa instead of throwing ReferenceError.
63+
if (typeof globalThis.window === 'undefined') {
64+
globalThis.window = globalThis as typeof globalThis & Window & typeof globalThis;
65+
}
66+
67+
6068
export const snapshot = snapshotImpl as (
6169
page: Page,
6270
options: {flags?: Flags},

0 commit comments

Comments
 (0)