Skip to content

Sync/common v8 2026 03 19#76

Merged
miccy merged 20 commits intomainfrom
sync/common-v8-2026-03-19
Mar 22, 2026
Merged

Sync/common v8 2026 03 19#76
miccy merged 20 commits intomainfrom
sync/common-v8-2026-03-19

Conversation

@miccy
Copy link
Copy Markdown
Contributor

@miccy miccy commented Mar 22, 2026

Summary

Scope

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • CI/Tooling
  • Breaking change

Verification

  • I ran the repository verification command successfully (bun verify or repo equivalent)
  • I added/updated tests where needed
  • I updated docs where needed

Governance

  • No secrets or credentials introduced
  • CODEOWNERS-relevant changes requested proper reviewers

Linked Issues

Summary by CodeRabbit

Poznámky k vydání

  • New Features

    • Added snapshot() method to SharedResource for monitoring idle and mutex states.
    • Enhanced StructuralMap to support undefined as a valid key type alongside JSON-like values and byte arrays.
  • Bug Fixes

    • Improved disposal and lifecycle management in shared resource handling.
  • Chores

    • Updated development and peer dependencies across all packages and example projects to latest compatible versions.

steida and others added 20 commits March 16, 2026 22:16
Allow undefined as a valid StructuralKey and as an explicit object property value (so undefined is distinct from a missing property). Add serialization for undefined, relax the previous prohibition on undefined in object properties, and update the error message to mention undefined. Refactor key-id caching to a module-level WeakMap and simplify serialization helpers (remove per-call WeakMap parameter, use Array.from and toSorted). Update tests and the changeset documentation and add an example for StructuralMap usage.
Expose a snapshot API and harden resource lifecycle semantics.

- Add SharedResource.snapshot and SharedResourceSnapshot (isIdle + mutex snapshot) for monitoring.
- Document that Resource lifecycle ops (acquire/release/set) run to completion once started and should be awaited; import SemaphoreSnapshot type.
- Make createSharedResource return a snapshot implementation that uses mutex.snapshot().
- Improve disposal ordering and callbacks: use an AsyncDisposableStack when disposing current resources and invoke onDisposed in a safe, controlled way.
- For createSharedResourceByKey, run the onDisposed callback under the key mutex and only delete/dispose the keyed entry when it is still idle and still the same sharedResource, preventing stale callbacks from removing newly reacquired keys.
- Update tests to add onDispose hooks, new run snapshot counting helpers, reorganize idleDisposeAfter tests, and adjust expectations to the new unabortable/await semantics and disposal timing.

These changes improve observability and make resource cleanup and keyed eviction robust against races and aborted callers.
Refactor SharedEvolu lifecycle management to use createSharedResourceByKey instead of a manual Map+mutex. Initialize sharedEvolusByName via stack.use and run, and use a run.create() wrapper (initSharedWorkerRun) with assertNotAborted when acquiring the resource. addPorts now accepts a releaseSharedEvolu callback and asserts not to be called after disposal; on Evolu Dispose it removes the dbWorkerPort and invokes releaseSharedEvolu. Mark isDisposed in the async disposer to prevent post-disposal usage. Cleanup: remove createMutexByKey usage and related code, import createSharedResourceByKey, drop the unused appOwner parameter, and simplify concurrent acquisition/creation logic.
Source upstream commit: a573d02

Port scope: not-applicable
Source upstream commit: ccb0871

Port scope: not-applicable
Source upstream commit: d8e61d2

Port scope: adapted
Source upstream commit: 4aa57bd

Port scope: adapted
Source upstream commit: dfa138c

Port scope: adapted
Copilot AI review requested due to automatic review settings March 22, 2026 22:16
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6681d28f-0188-4ecb-b7bd-379600733427

📥 Commits

Reviewing files that changed from the base of the PR and between b13c409 and aa1a5e4.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (25)
  • .changeset/structural-map-uint8array.md
  • biome.json
  • examples/angular-vite-pwa/package.json
  • examples/astro/package.json
  • examples/react-expo/package.json
  • examples/react-nextjs/package.json
  • examples/react-vite-pwa/package.json
  • examples/svelte-vite-pwa/package.json
  • examples/tanstack-start/package.json
  • examples/vue-vite-pwa/package.json
  • package.json
  • packages/bun/package.json
  • packages/common/package.json
  • packages/common/src/Resource.ts
  • packages/common/src/StructuralMap.ts
  • packages/common/src/Task.ts
  • packages/common/src/Test.ts
  • packages/common/src/local-first/Evolu.ts
  • packages/common/src/local-first/Shared.ts
  • packages/common/test/Resource.test.ts
  • packages/common/test/StructuralMap.test.ts
  • packages/common/test/Task.test.ts
  • packages/common/test/local-first/Evolu.test.ts
  • packages/react-native/package.json
  • packages/svelte/package.json

📝 Walkthrough

Walkthrough

Tato PR kombinuje aktualizace závislostí v mnoha package.json souborech, zdokumentační změny v changesetu, a významné refaktoringy v core modulech Resource.ts, StructuralMap.ts, Shared.ts a Task.ts, včetně nových metod snímků stavu a vylepšeného řízení životního cyklu zdrojů.

Changes

Cohort / File(s) Souhrn
Aktualizace závislostí
Root package.json, examples/*/package.json, packages/bun/package.json, packages/common/package.json, packages/react-native/package.json, packages/svelte/package.json, biome.json
Rutinní aktualizace verzí vývojových a runtime závislostí (@biomejs/biome, turbo, tailwindcss, astro, expo, svelte a další) bez změn konfigurace nebo chování.
StructuralMap – typ a caching
packages/common/src/StructuralMap.ts
Rozšíření typu StructuralKey o undefined, zrušení oddělených StructuralArrayInput/StructuralObjectInput typů; refaktorování id cachování z lokální WeakMap na úroveň modulu; zjednodušení serializace s dedikovanou "d:undefined" komponentou.
Resource – snapshot a životní cyklus
packages/common/src/Resource.ts
Přidání metody snapshot() a rozhraní SharedResourceSnapshot; aktualizace dokumentace semantiky acquire/release/set; refaktorování sekvence likvidace v createSharedResource a změna chování zpětného volání v createSharedResourceByKey.
Task – idle state
packages/common/src/Task.ts
Přidání isIdle: boolean do SemaphoreSnapshot; zjednodušení kontrol při likvidaci pomocí derived idle stavu.
Shared – sdílená evolu s resource abstrakčí
packages/common/src/local-first/Shared.ts
Nahrazení manual mutex + Map caching pomocí createSharedResourceByKey; přidání releaseSharedEvolu callbacku; zavádění isDisposed stavu a vylepšená správa portů.
Dokumentace a čistka
.changeset/structural-map-uint8array.md, packages/common/src/local-first/Evolu.ts, packages/common/src/Test.ts
Aktualizace popisu changesetu, odebrání TODO komentáře, rozšíření JSDoc pro testWaitForMacrotask.
Testy
packages/common/test/Resource.test.ts, packages/common/test/StructuralMap.test.ts, packages/common/test/Task.test.ts, packages/common/test/local-first/Evolu.test.ts
Nové a aktualizované testy pro snapshot API, idle eviction, undefined klíče, a aktualizované inline snímky.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

upstream, feat, update

Suggested reviewers

  • Jakub-coding99

Poem

🐰 Struktury a mapy, čísly zdobené,
Zdroje teď mají snímky, zjednodušené.
S isIdle polem a novým snapshot v toku,
Evoluční sdílení běží v toku,
Refaktoring králíčka vám přinese krok! 🥕

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/common-v8-2026-03-19

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@miccy miccy marked this pull request as ready for review March 22, 2026 22:17
@miccy miccy requested a review from a team as a code owner March 22, 2026 22:17
@miccy miccy merged commit ed457ae into main Mar 22, 2026
4 of 36 checks passed
@miccy miccy deleted the sync/common-v8-2026-03-19 branch March 22, 2026 22:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates dependencies across the monorepo and refactors local-first shared-worker resource management by expanding structural-key support and adding new snapshot/idle-state introspection to concurrency/resource primitives.

Changes:

  • Bumped various framework/tooling dependencies (Svelte, Expo, Biome, Turbo, etc.) and refreshed bun.lock.
  • Extended StructuralKey/StructuralMap to support undefined (including distinguishing undefined from missing object properties) and updated tests/docs accordingly.
  • Added isIdle to SemaphoreSnapshot, added snapshot() to SharedResource, and refactored SharedWorker Evolu instance tracking to use createSharedResourceByKey.

Reviewed changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/svelte/package.json Bump Svelte dependency + peer range.
packages/react-native/package.json Update Expo/RN-related deps.
packages/common/test/local-first/Evolu.test.ts Update integration snapshot expectations.
packages/common/test/Task.test.ts Update semaphore snapshot assertions for new isIdle.
packages/common/test/StructuralMap.test.ts Add coverage for undefined structural keys and object-property distinction.
packages/common/test/Resource.test.ts Add tests for SharedResource.snapshot + keyed idle-eviction disposal behavior.
packages/common/src/local-first/Shared.ts Refactor shared-worker Evolu lifecycle to keyed shared resources and explicit acquire/release.
packages/common/src/local-first/Evolu.ts Remove a TODO comment.
packages/common/src/Test.ts Expand testWaitForMacrotask documentation.
packages/common/src/Task.ts Add isIdle to SemaphoreSnapshot and use it for keyed semaphore cleanup.
packages/common/src/StructuralMap.ts Extend StructuralKey to include undefined, update serialization and error messages.
packages/common/src/Resource.ts Add SharedResource.snapshot, refine lifecycle docs, adjust keyed shared-resource cleanup.
packages/common/package.json Bump kysely.
packages/bun/package.json Bump bun-types.
package.json Bump Biome/Turbo/typedoc-plugin-markdown dev deps.
examples/vue-vite-pwa/package.json Bump vue-tsc.
examples/tanstack-start/package.json Bump @tanstack/react-router.
examples/svelte-vite-pwa/package.json Bump Svelte.
examples/react-vite-pwa/package.json Bump Tailwind deps.
examples/react-nextjs/package.json Bump Next + Tailwind deps.
examples/react-expo/package.json Bump Expo and related deps.
examples/astro/package.json Bump Astro + @astrojs/react.
examples/angular-vite-pwa/package.json Bump Angular + Tailwind deps.
bun.lock Lockfile updates for the above version bumps.
biome.json Update Biome schema URL to match bumped Biome version.
.changeset/structural-map-uint8array.md Refresh StructuralMap changeset narrative and add example.

{
onDispose,
}: {
onDispose?: (() => void) | undefined;
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option property type onDispose?: (() => void) | undefined is redundant because an optional property already includes undefined. Simplify to onDispose?: () => void to reduce noise and keep types consistent.

Suggested change
onDispose?: (() => void) | undefined;
onDispose?: () => void;

Copilot uses AI. Check for mistakes.
Comment on lines 526 to 528
evoluPorts.delete(evoluPortId);
dbWorkerPorts.delete(dbWorkerPort);
rowsByQueryByEvoluPortId.delete(evoluPortId);
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When handling an Evolu port "Dispose", the code removes dbWorkerPort from dbWorkerPorts but does not clear activeDbWorkerPort when it equals that port. This can leave ensureQueueProcessing() posting messages to a closed/removed leader port until the heartbeat timeout fires. Consider explicitly handling if (activeDbWorkerPort === dbWorkerPort) by clearing the leader timeout and setting activeDbWorkerPort = null (and aborting/cancelling any in-flight queue processing) before continuing.

Copilot uses AI. Check for mistakes.
Comment on lines +128 to +129
const initSharedWorkerRun = run.create();
const sharedEvolusByNamePromise = run.orThrow(
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initSharedWorkerRun is created with run.create() but never disposed or registered in the returned AsyncDisposableStack. Since run.create() creates a long-lived daemon Run, this will remain as a child run for the lifetime of the root daemon (and keep any future child fibers reachable). Register it in stack (e.g. stack.use(initSharedWorkerRun)) so it’s disposed when the shared worker stack is disposed.

Suggested change
const initSharedWorkerRun = run.create();
const sharedEvolusByNamePromise = run.orThrow(
const initSharedWorkerRun = stack.use(run.create());
const sharedEvolusByNamePromise = initSharedWorkerRun.orThrow(

Copilot uses AI. Check for mistakes.

const getKeyId = (key: K): string =>
serializeStructuralKey(key, keyIdByObject, new Set<object>());
const getKeyId = (key: K): string => serializeStructuralKey(key, new Set());
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serializeStructuralKey expects a Set<object> for cycle detection, but getKeyId passes new Set() which defaults to Set<any>. Explicitly typing this as new Set<object>() keeps the helper fully type-safe and avoids accidental non-object values being added later.

Suggested change
const getKeyId = (key: K): string => serializeStructuralKey(key, new Set());
const getKeyId = (key: K): string =>
serializeStructuralKey(key, new Set<object>());

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants