fix(@Persist): prevent null auto-vivification on read operations#93
Open
apankov1 wants to merge 9 commits intocloudflare:mainfrom
Open
fix(@Persist): prevent null auto-vivification on read operations#93apankov1 wants to merge 9 commits intocloudflare:mainfrom
@Persist): prevent null auto-vivification on read operations#93apankov1 wants to merge 9 commits intocloudflare:mainfrom
Conversation
The proxy's get() handler was mutating null/undefined properties to {}
when reading them. This corrupted domain values and caused [object Object]
serialization in D1 journaling.
Fix: Return null/undefined as-is instead of auto-vivifying them.
Also updates test to use actual createDeepProxy via __test export.
- Added test for undefined property values (same behavior as null) - Added test for falsy but valid values (0, false, "")
Add optionalOwner nullable field to persist example showing that null values are correctly preserved through the @persist proxy.
@Persist): prevent null auto-vivification on read operations
The error handler was creating {} and returning a new proxy on ANY error,
which caused:
1. Silent data corruption (original value replaced with {})
2. Infinite proxy recursion leading to heap overflow
Fix: Return undefined on error instead of auto-vivifying.
2 tasks
fix(`@Persist`): prevent heap overflow in error handler
Fix Actor configuration override for custom upgrade paths
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.
Summary
The
@Persistproxy'sget()handler was incorrectly auto-vivifyingnullandundefinedvalues to{}during read operations. This caused:JSON.stringify({})produces"[object Object]"strings instead ofNULLvalues in the databaseRoot Cause
In
createDeepProxy, when accessing a property that exists but has anullorundefinedvalue, the proxy was creating a new empty object and assigning it back to the target:Fix
Return
nullandundefinedvalues as-is without wrapping or auto-vivification:Test Plan
{}Related
@Persist): prevent heap overflow in error handler #94 - Separate fix for error handler heap overflow in same code areaCode in this PR was AI-assisted and exercised against a pet project that experienced the bug.