Repository navigation
fix: keep own __proto__ keys in eval JSON results - #53
Merged
Merged
Conversation
The in-app serializer copied entries into a {} literal, so an own
__proto__ key swapped that object's prototype instead of becoming a key.
evalJson dropped the key. evalJsonAsync stored the swapped object, every
poll read then failed to reserialize it, and the loop retried those
failures until it reported a finished operation as still-pending.
Build serializer records with a null prototype. The client decodes them
with Object.fromEntries, which defines the key as own data on a plain
object, so nothing can pollute a prototype. A poll that throws in-app is
deterministic, so it now surfaces at once instead of being retried.
Fixes #44
chhoumann
marked this pull request as ready for review
October 24, 2026 14:29
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.
Fixes #44.
Problem
An own
__proto__key in an eval result did not survive the trip to the caller.client.dev.evalJson(...)returned{"savedFeeds":{}}, so the key was silently dropped.client.dev.evalJsonAsync(...)timed out with reasonstill-pending. The operation had already finished in Obsidian.Root cause
The in-app serializer copied entries into a
{}literal.next["__proto__"] = valuechanges that object's prototype and does not create a key. On the sync path,JSON.stringifythen skipped the missing key. On the async path, the swapped object was stored in the registry. Every poll read reserialized it, hit the non-plain-object check, and threw. The poll loop treated each of those throws as transient until the deadline expired.Fix
Object.create(null), so__proto__is an ordinary own key.JSON.parseandObject.fromEntries. Both define the key as own data on an object whose prototype isObject.prototype, so a decoded result cannot pollute any prototype. The tests assert this.DevEvalError) is deterministic, so it is now rethrown at once instead of being reported asstill-pending.Verification
Tested against a real Obsidian 1.13.7 instance started with
obsidian-e2e start, using a consumer project that installs the packed tarball:The regression tests are committed before the fix and fail without it. They cover the sync path, the async path, and a poll read that fails in-app.