Repository navigation
Conversation
RuntimeDecorator does not forward createValueFromJsonUtf8 to the plain runtime, so decorated runtimes (including WithRuntimeDecorator and the thread-safe Hermes runtime) fall back to the JSON.parse based default in jsi::Runtime instead of the plain runtime's implementation. TracingRuntime relied on that fallback to record JSON parsing, so it now overrides the method and keeps using the default explicitly. Traces are unchanged.
mrousavy
force-pushed
the
decorator-json
branch
from
September 26, 2026 13:16
b543244 to
cb6bd82
Compare
lavenzg
reviewed
Oct 7, 2026
| return plain_.utf8(s); | ||
| } | ||
|
|
||
| Value createValueFromJsonUtf8(const uint8_t* json, size_t length) override { |
Contributor
There was a problem hiding this comment.
Why change the public access of this method to protected?
|
@lavenzg has imported this pull request. If you are a Meta employee, you can view this in D124177263. |
This branch was successfully deployed
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
RuntimeDecoratordoesn't forwardcreateValueFromJsonUtf8to the plain runtime, so decorated runtimes use theJSON.parse-based default from jsi.cpp instead of the plain runtime's parser. For Hermes that meansmakeThreadSafeHermesRuntimeand anything built onWithRuntimeDecoratornever reach the native parser from a3f615c.I think this was missed rather than chosen.
WithRuntimeDecoratoralready overrides it (added in c2a0da2 asAroundplusRD::createValueFromJsonUtf8), which only makes sense ifRuntimeDecoratorforwards it. Today thatRD::call lands in the default, so it takes oneAroundplus several nested ones forglobal,getProperty,createStringFromUtf8andcall. It's also observable: on a thread-safe runtime, afterJSON.parse = () => 'hijacked',Value::createFromJsonUtf8returns'hijacked', and afterdelete globalThis.JSONit throws. A plainHermesRuntimeparses normally in both cases.TracingRuntimerelies on the current behavior. JSON parsing only shows up in traces because the default splits into tracedglobal/getProperty/callcalls. Forwarding alone would hand back a value from the plain runtime with no def, and replay would hit the "has no def" assert inuseObjectID. SoTracingRuntimenow overridescreateValueFromJsonUtf8and callsjsi::Runtime::createValueFromJsonUtf8explicitly. That runs the same code as before, so traces are unchanged and there's no new record type. If you'd prefer a dedicated SynthTrace record I can do that instead.A side effect: decorators that watched JSON parsing through
global/getProperty/callnow need to overridecreateValueFromJsonUtf8, like every other forwarded method. For example,TimedRuntimeno longer counts JSON parsing under itscalltimer. The other methods decorators don't forward yet are thecreateError*family (#2203) andString::length(#2205). React Native'sdecorator.hhas the same gap.Test Plan
New tests:
JSITest.CreateValueFromJsonUtf8Testchecks that parsing through aRuntimeDecoratorreaches the wrapped runtime, and keeps coverage of the jsi.cpp default through a decorator that overrides back to it. It callsouter.createValueFromJsonUtf8directly to check that the override remains public.HermesRuntimeTest.CreateValueFromJsonUtf8IgnoresGlobalJSONreplacesJSON.parseand checks that parsing still works, on the plain and thread-safe runtimes.SynthTraceReplayTest.CreateValueFromJsonUtf8Replayparses on the tracing runtime, uses the result from native code, and replays with verification.Without the change the first two fail (the second only on the thread-safe runtime). With only the
decorator.hpart, the SynthTrace test aborts inuseObjectID. With the full change all pass, and so does the fullAPITestsbinary (360 tests) in a Debug + ASan build.APILeanTestsalso passes.The direct call fails to compile with the previous header because
createValueFromJsonUtf8is protected. With this revision,cmake --build cmake-build-asan --target check-hermes -j 12passes in Debug + ASan: 4,126 expected passes, 6 expected failures, and 197 unsupported tests. Node-API checks: 41 passes and 23 skips.