Chore/sibujs hardening followups#38
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Completes the duplicate-runtime hardening started in 3.3.1. When a bundler loads the framework's modules more than once on a page (e.g. Vite/esbuild dependency pre-bundling, which can serve the same chunk twice), module-scoped singletons split into independent copies and silently misbehave. 3.3.1 fixed the reactive core; this PR (3.3.2) sweeps the remaining coordination singletons via the same first-copy-wins
globalThisregistry, plus two supporting tooling fixes.Singletons hardened
createId()— the unique-id counter is now shared, so two copies can't both hand outsibu-1(was breaking a11y pairingaria-labelledby/for+idand SSR hydration).ssr-context— the AsyncLocalStorage instance + fallback store are shared, soenableSSR()in one copy is observed byisSSR()in another (prevents client-only effects running during a server render, and per-request state bleed across copies).routerglobalRouter— the global router instance is shared, so navigation /Outlet/Linkhelpers in a duplicatedpluginschunk see the router created bycreateRouter()in the first copy (no spurious "Router not initialized").Audited and already safe:
context()(instance-owned signal) and the devtools hook (globalThis).Tooling
__SIBU_VERSION__build define (tsup.config.ts) — the duplicate-runtime dev warning now prints real versions (active: 3.3.2, …) instead ofdev.Create 10,000 effectsbench (was a single un-warmediterations: 1shot swinging ~10→20 ms) to measure create-only cost, warmed and averaged over 12 rounds with disposal outside the timed region (~14% spread, under the gate), and regenerated the stalebench-baseline.jsonsobench:checkis trustworthy again.Regression tests for
createIdandssr-contextcross-instance sharing added totests/duplicate-instance.test.ts(fail before, pass after). The router shares the identical mechanism but is verified via the full router suite (247 tests) for single-instance safety — a cross-instance test is omitted becausecreateRouterneeds DOM, which conflicts with the node-env esbuild double-eval harness. Version bumped 3.3.1 → 3.3.2 with CHANGELOG and docs-site badges.Related Issue
Closes #
Type of Change
Checklist