Some checks are pending
build-gate / build (push) Waiting to run
initializeMap is async. If its component unmounts while it waits (a studio tab switch, a composite swapping views), Vue nulls containerRef and the next dereference threw "Cannot read properties of null (reading 'getRootNode')" from ensureEngineCSS. check:studio-all hit it about 1 run in 4 (gospel-dashboard); gospel-plugin found a second site one await later (containerRef.value.clientWidth after the animation frame). initializeMap now checks the ref after each of its three awaits and returns silently when it is gone, and ensureEngineCSS returns on a null element. An unmounted pane is normal, not an error, so nothing is logged. The ref is the only liveness signal: requiring isConnected too would silently stop maps that mount into a subtree before it is attached. Proof, deterministic in both directions: - check:map-unmount-mid-init holds mapbox-gl.js, opens a map plugin in the studio, switches away (destroying the pane), then releases the script. Before: FAIL 2/2 runs (research-map, doxa-simple-map threw the production error). After: PASS 2/2 across research-map, gospel-dashboard and doxa-simple-map. - check:map-unmount-race (gospel-plugin's browser-free test, adopted): the guarded ensureEngineCSS resolves; with the guard stripped it throws the exact message. - No regression: check:studio-all passes 31/31, and 19 plugins still create a live map canvas, as before. check:shared-reached now tracks this change with a regex marker (a control-flow fix has no literal that survives minification). It reports 12 consumer bundles still to rebuild. Verified: rebuilding doxa-simple-map moves it to "carries it".
30 lines
1.7 KiB
JavaScript
30 lines
1.7 KiB
JavaScript
/* check-map-unmount-guard — the fast, browser-free half of the unmount-race proof (by gospel-plugin,
|
|
adopted into internal/ by the studio lane; the end-to-end half is check-map-unmount-mid-init.mjs).
|
|
|
|
Proves the guard by REPRODUCING the race against the real file: take the shipped source,
|
|
run its ensureEngineCSS with a null element (what an unmounted pane hands it), and do the
|
|
same against a copy with the guard stripped. One must throw, the other must not — a fix
|
|
that cannot be shown to matter is not evidence. */
|
|
import { readFileSync } from 'node:fs'
|
|
const SRC = readFileSync('library/composables/useMapInstance.js', 'utf8')
|
|
const grab = (src) => {
|
|
const i = src.indexOf('async function ensureEngineCSS')
|
|
const j = src.indexOf('\n}\n', i)
|
|
return src.slice(i, j + 2)
|
|
}
|
|
const body = grab(SRC)
|
|
const stripped = body.replace(' if (!element) return\n', '')
|
|
if (stripped === body) { console.error('CONTROL BROKEN — the guard line was not found, so the negative arm proves nothing.'); process.exit(1) }
|
|
|
|
const run = async (fnSrc) => {
|
|
const f = new Function('ShadowRoot', `${fnSrc}; return ensureEngineCSS`)(class ShadowRoot {})
|
|
try { await f(null, 'https://example.invalid/x.css'); return 'resolved' } catch (e) { return `threw: ${e.message}` }
|
|
}
|
|
const withGuard = await run(body)
|
|
const without = await run(stripped)
|
|
console.log(` guarded -> ${withGuard}`)
|
|
console.log(` unguarded -> ${without}`)
|
|
const ok = withGuard === 'resolved' && /getRootNode/.test(without)
|
|
console.log(ok ? 'UNMOUNT-RACE: PASS — the guard turns studio\'s crash into a clean return.'
|
|
: 'UNMOUNT-RACE: FAIL — the arms did not separate; this proves nothing.')
|
|
process.exit(ok ? 0 : 1)
|