From 2aa944a80f176dbc30d1862f0f3ad1ff49426928 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 4 May 2026 19:48:19 +0200 Subject: [PATCH] fix(core): use btoa() instead of window.Buffer.from() for base64 encoding window.Buffer is a Node.js API that is not natively available in browsers. It was apparently polyfilled in the webpack bundle by a dependency, but the polyfill is absent in environments like headless Electron (Cypress). This went undetected because browserslist-useragent-regexp < 4.1.4 had a bug where an empty browser set produced /(?:)/ (matches everything). Electron matched as "supported" and the redirect code was never reached. browserslist-useragent-regexp 4.1.4 fixed that bug (PR #1583: faithfully match an empty set of browsers), generating /[]/ instead. Electron 118 no longer matches as supported, the redirect path is now exercised, and window.Buffer.from() throws: TypeError: Cannot read properties of undefined (reading 'from') The fix replaces window.Buffer.from(str).toString('base64') with the native browser btoa(str), which has been universally available since before our minimum browser support baseline and requires no polyfill. Fixes: #57920 Signed-off-by: Anna Larch --- core/src/utils/RedirectUnsupportedBrowsers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/utils/RedirectUnsupportedBrowsers.js b/core/src/utils/RedirectUnsupportedBrowsers.js index e83711322df..1e75b56a70b 100644 --- a/core/src/utils/RedirectUnsupportedBrowsers.js +++ b/core/src/utils/RedirectUnsupportedBrowsers.js @@ -33,7 +33,7 @@ export function testSupportedBrowser() { // redirect to the unsupported warning page if (window.location.pathname.indexOf(redirectPath) === -1) { const redirectUrl = window.location.href.replace(window.location.origin, '') - const base64Param = window.Buffer.from(redirectUrl).toString('base64') + const base64Param = btoa(redirectUrl) history.pushState(null, null, `${redirectPath}?redirect_url=${base64Param}`) window.location.reload() }