Repository navigation
Conversation
Summary: `JSError(rt, message)` still creates its value by looking up `globalThis.Error` and calling it, which predates `IRuntime::createError`. It now uses `rt.createError(...)` like the `JSError::createXError` factories, with the same try/catch fallback. The default `Runtime::createError` makes the same global call, so runtimes without a native implementation behave as before. On Hermes every `JSError` thrown from native code skips a global lookup and a JS call, and `message`, `stack` and `what()` come out the same. `RuntimeDecorator` and `WithRuntimeDecorator` didn't forward the `createError` family, so decorated runtimes (the thread-safe runtime, `TracingRuntime`) quietly fell back to the global constructor calls. They forward to `plain()` now, through `Around` for `WithRuntimeDecorator`, and they're public like in `jsi::Runtime`. One visible difference on Hermes, same as the other `createXError` APIs: if user code replaced or deleted `globalThis.Error`, `JSError(rt, message)` no longer calls the replacement and creates a real `Error` anyway. X-link: facebook/hermes#2203 Differential Revision: D124178378 Pulled By: lavenzg
|
@lavenzg has exported this pull request. If you are a Meta employee, you can view the originating Diff in D124178378. |
This branch has not been 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:
JSError(rt, message)still creates its value by looking upglobalThis.Errorand calling it, which predatesIRuntime::createError. It now usesrt.createError(...)like theJSError::createXErrorfactories, with the same try/catch fallback. The defaultRuntime::createErrormakes the same global call, so runtimes without a native implementation behave as before. On Hermes everyJSErrorthrown from native code skips a global lookup and a JS call, andmessage,stackandwhat()come out the same.RuntimeDecoratorandWithRuntimeDecoratordidn't forward thecreateErrorfamily, so decorated runtimes (the thread-safe runtime,TracingRuntime) quietly fell back to the global constructor calls. They forward toplain()now, throughAroundforWithRuntimeDecorator, and they're public like injsi::Runtime.One visible difference on Hermes, same as the other
createXErrorAPIs: if user code replaced or deletedglobalThis.Error,JSError(rt, message)no longer calls the replacement and creates a realErroranyway.X-link: facebook/hermes#2203
Differential Revision: D124178378
Pulled By: lavenzg