Files
orca/config/scripts/electron-runtime-floor.test.ts
T
Neil 7012f8455c [CI] Advance debounce clocks and simplify test fixtures (#26996)
* [CI] Advance test debounce clocks and remove workflow text checks

* test: use a representative PowerShell command fixture
2026-10-09 15:35:35 -07:00

49 lines
1.8 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('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)
})
})