Files
Brennan Benson 890ad4d8aa Prevent new blocking work on Electron main in CI (#41263)
* WIP: guard blocking main-process APIs with file ratchets

* Cover declared SQLite receivers and preserve daemon guards

* Cover SQL iteration and shared synchronous IPC in ratchets
2026-11-11 16:24:55 -08:00

26 lines
788 B
JavaScript

import { existsSync, readFileSync } from 'node:fs'
import { isTestOnlySourcePath } from './test-only-source-path.mjs'
// Exact entry files only: dependencies remain guarded, even when a worker imports them.
const entries = JSON.parse(
readFileSync(new URL('../../../main-blocking-worker-entries.json', import.meta.url), 'utf8')
)
for (const [file, reason] of Object.entries(entries)) {
if (
!file.startsWith('src/main/') ||
!reason.trim() ||
!existsSync(new URL(`../../../../${file}`, import.meta.url))
) {
throw new Error(`Invalid worker entry: ${file}`)
}
}
export function isMainBlockingSource(file) {
return (
/\.[cm]?[jt]sx?$/.test(file) &&
!/\.d\.[cm]?ts$/.test(file) &&
!isTestOnlySourcePath(file) &&
!Object.hasOwn(entries, file)
)
}