fix(partykit): preserve delete tombstones#284
Merged
jamesgpearce merged 2 commits intotinyplex:mainfrom Feb 10, 2026
Merged
Conversation
Contributor
Author
|
Small REPL proof for why a reviver cannot preserve delete tombstones: const UNDEFINED = '\uFFFC';
const jsonParseWithUndefinedOld = (str) =>
JSON.parse(str, (_key, value) => (value === UNDEFINED ? undefined : value));
const replaceUndefinedString = (value) => {
if (value === UNDEFINED) {
return undefined;
}
if (Array.isArray(value)) {
return value.map(replaceUndefinedString);
}
if (value && typeof value === 'object') {
for (const key of Object.keys(value)) {
value[key] = replaceUndefinedString(value[key]);
}
}
return value;
};
const jsonParseWithUndefinedNew = (str) =>
replaceUndefinedString(JSON.parse(str));
const serializedChanges =
'{"feeding-sessions":{"1767445910545":"\\uFFFC"}}';
const parsedOld = jsonParseWithUndefinedOld(serializedChanges);
const parsedNew = jsonParseWithUndefinedNew(serializedChanges);
console.log('parsedOld:', parsedOld);
console.log(
'old keeps row key:',
'1767445910545' in parsedOld['feeding-sessions'],
);
console.log('parsedNew:', parsedNew);
console.log(
'new keeps row key:',
'1767445910545' in parsedNew['feeding-sessions'],
);
console.log(
'new row value is undefined:',
parsedNew['feeding-sessions']['1767445910545'] === undefined,
);Expected output:
|
Add a PartyKit client/server integration test harness that verifies add and update persistence, including custom path and prefix settings. Keep a delete assertion that currently fails to capture issue tinyplex#281 behavior in server storage.
Encode PartyKit messages with undefined-aware JSON and decode them without using a reviver so tombstone keys are preserved. This keeps delete changes intact across transport instead of dropping row and cell deletions during parse. Fixes: tinyplex#281
9a05423 to
774c607
Compare
Contributor
|
Amazing - thank you! |
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.
fix(partykit): preserve delete tombstones
Encode PartyKit messages with undefined-aware JSON and decode them without using a reviver so tombstone keys are preserved. This keeps delete changes intact across transport instead of dropping row and cell deletions during parse.
Fixes: #281