Files
orca/config/scripts/electron-runtime-floor.test.ts
T
Jinwoo Hong e8d8f2f0b3 fix(deps): take Electron 43.7.5 so detached webviews stop blanking browser tabs (#23586)
Electron 43.7.0 threw 'Invalid guestInstanceId' from <webview>'s
disconnectedCallback for a loaded guest (electron/electron#53989), so a
webview React removed and re-inserted kept a dead guest id: the tab went
blank, reload did nothing, and the destroyed listener never fired.
43.7.4 (electron/electron#54097) returns early when the guest is gone.

Raises the runtime floor test to 43.7.4 so a downgrade cannot re-ship it.

Fixes STA-8757
2026-09-28 13:58:48 -04:00

62 lines
2.1 KiB
TypeScript

import { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
/**
* Why a floor and not just a pin: Electron 43.5.0/43.6.0 set and unset `GDK_GL`
* around `gtk_init()` while FontConfig warmed up on a pool thread, and below
* glibc 2.41 that frees `environ` under a concurrent `getenv()` — a launch-time
* use-after-free on every Ubuntu we support (stablyai/orca#20081). 43.7.0 stops
* freeing the published `environ`. 43.7.0 itself threw `Invalid guestInstanceId` when a
* loaded `<webview>` left the DOM, which blanked browser tabs React re-inserted
* (electron/electron#53989); 43.7.4 fixes it. A downgrade past either re-ships the bug,
* and nothing else in the tree would notice.
*/
const MINIMUM_ELECTRON_VERSION = '43.7.4'
function parseVersion(specifier: string): [number, number, number] {
const match = /(\d+)\.(\d+)\.(\d+)/.exec(specifier)
if (!match) {
throw new Error(`unparseable Electron version: ${specifier}`)
}
return [Number(match[1]), Number(match[2]), Number(match[3])]
}
function meetsRuntimeFloor(specifier: string): boolean {
const version = parseVersion(specifier)
const floor = parseVersion(MINIMUM_ELECTRON_VERSION)
for (const [index, part] of version.entries()) {
if (part !== floor[index]) {
return part > floor[index]
}
}
return true
}
describe('electron runtime floor', () => {
it.each([
['42.9.0', false],
['43.6.0', false],
['43.7.0', false],
['43.7.3', false],
['43.7.4', true],
['43.7.5', true],
['43.8.0', true],
['44.0.0', true]
])('reads %s as meeting the floor: %s', (specifier, expected) => {
expect(meetsRuntimeFloor(specifier)).toBe(expected)
})
it('pins Electron at or above the glibc environ-race and webview-detach fixes', () => {
const packageJson = JSON.parse(
readFileSync(join(__dirname, '../../package.json'), 'utf-8')
) as { devDependencies: Record<string, string> }
const specifier = packageJson.devDependencies.electron
expect(
meetsRuntimeFloor(specifier),
`electron ${specifier} is below the ${MINIMUM_ELECTRON_VERSION} runtime floor`
).toBe(true)
})
})