fix(data): fromData resets nonPersistent space to defaults#142
Merged
Conversation
…0.9.78) `db.fromData()` restored only the persistent side and left the negative-ID nonPersistent space (nonPersistent resources + entities) holding the loading store's pre-load live values — inconsistent with `db.reset()`, which reverts them to defaults. Because nonPersistent data is never captured by `toData()`, the only correct value after a load is the default; leaving the stale value leaks it across a same-instance load (e.g. Save-As -> Load keeping dead blob URLs forever). Existing tests missed this because every fromData test loaded into a freshly-constructed store, whose nonPersistent resources were already at their defaults. Add red-green coverage that loads into a populated (non-fresh) store. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Run `pnpm run bump` so the root and every workspace package move to 0.9.78 in lockstep, rather than hand-editing @adobe/data alone. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
db.fromData()restored only the persistent side of the store and left the negative-ID nonPersistent space (nonPersistent resources + entities) holding the loading store's pre-load live values. This is inconsistent withdb.reset(), which reverts nonPersistent state to its schema defaults.Because nonPersistent data is never captured by
toData()(only its archetypecomponentNames, neverdata), the only correct value after a load is the default. Leaving the stale live value leaks it across a same-instance load — e.g. a Save-As → Load in the same session keeping every pre-loadblob:URL forever (the downstream FFP "video clips not visible after reopen" thumbnail bug).Fix
core.fromDatanow resets the nonPersistent location table and zeroes nonPersistent archetype rows before restoring the persistent side (which is fully overwritten anyway). The store layer then re-seeds nonPersistent resource defaults via its existingrowCount === 0re-init guard. This mirrorsreset()exactly.Why existing tests missed it
Every
fromDatatest loaded a snapshot into a freshly-constructed store, whose nonPersistent resources were already at their defaults — so the assertions passed vacuously, not becausefromDatareset anything. Added red-green coverage that loads into a populated (non-fresh) store:Version bumped to
0.9.78.Testing
vitest run --project node— 1343 tests pass; new populated-store cases are red without the fix, green with it.