Repository navigation
Conversation
|
@lavenzg has exported this pull request. If you are a Meta employee, you can view the originating Diff in D124178378. |
lavenzg
force-pushed
the
export-D124178378
branch
from
October 13, 2026 17:13
1d1ca7e to
03e8d5b
Compare
lavenzg
pushed a commit
to lavenzg/react-native
that referenced
this pull request
Oct 13, 2026
…58961) 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 Test Plan: Two new tests in testlib.cpp. `JSErrorMessageTest` checks the value is an `Error` with the right message and a string stack, and that a counting `globalThis.Error` replacement gets called exactly as often as `rt.createError` calls it, so it holds for native and default implementations. `DecoratorCreateErrorTest` checks that all seven `createXError` calls, and `JSError`, reach the wrapped runtime once through both decorators, and that `Around` runs once. `JSErrorDoesNotInfinitelyRecurse` and `CreateJSErrorPropagatesOOMExceptionTest` run through decorators that use the default `Runtime::createError`. This keeps the missing-constructor fallback and OOM propagation covered, since both tests depend on changing `globalThis.Error`. `APITests` (ASan + Debug, macOS arm64, `HERMESVM_EXCEPTION_ON_OOM=ON`): 362/362 pass, including SynthTrace and all three OOM tests. Built with `-O1` and `HERMES_ENABLE_WERROR=ON`; the existing GoogleTest `uninitialized-const-pointer` warning is demoted for AppleClang 21. ```sh cmake --build cmake-build-asan-oom --target APITests -j 8 cmake-build-asan-oom/unittests/API/APITests ``` Before the OOM test adaptation, `CreateJSErrorPropagatesOOMExceptionTest` fails because it throws `JSError` instead of `JSOutOfMemoryError`. It passes with the decorator. The earlier checks with the `jsi.cpp` and `decorator.h` changes reverted also made the new JSI tests fail. Reviewed By: javache Differential Revision: D124178378 Pulled By: lavenzg
…58961) Summary: Pull Request resolved: react#58961 `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 Test Plan: Two new tests in testlib.cpp. `JSErrorMessageTest` checks the value is an `Error` with the right message and a string stack, and that a counting `globalThis.Error` replacement gets called exactly as often as `rt.createError` calls it, so it holds for native and default implementations. `DecoratorCreateErrorTest` checks that all seven `createXError` calls, and `JSError`, reach the wrapped runtime once through both decorators, and that `Around` runs once. `JSErrorDoesNotInfinitelyRecurse` and `CreateJSErrorPropagatesOOMExceptionTest` run through decorators that use the default `Runtime::createError`. This keeps the missing-constructor fallback and OOM propagation covered, since both tests depend on changing `globalThis.Error`. `APITests` (ASan + Debug, macOS arm64, `HERMESVM_EXCEPTION_ON_OOM=ON`): 362/362 pass, including SynthTrace and all three OOM tests. Built with `-O1` and `HERMES_ENABLE_WERROR=ON`; the existing GoogleTest `uninitialized-const-pointer` warning is demoted for AppleClang 21. ```sh cmake --build cmake-build-asan-oom --target APITests -j 8 cmake-build-asan-oom/unittests/API/APITests ``` Before the OOM test adaptation, `CreateJSErrorPropagatesOOMExceptionTest` fails because it throws `JSError` instead of `JSOutOfMemoryError`. It passes with the decorator. The earlier checks with the `jsi.cpp` and `decorator.h` changes reverted also made the new JSI tests fail. Reviewed By: javache Differential Revision: D124178378 Pulled By: lavenzg
lavenzg
force-pushed
the
export-D124178378
branch
from
October 13, 2026 17:17
03e8d5b to
66f0e2f
Compare
meta-codesync Bot
pushed a commit
to facebook/hermes
that referenced
this pull request
Oct 13, 2026
Summary: X-link: react/react-native#58961 `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. Pull Request resolved: #2203 Test Plan: Two new tests in testlib.cpp. `JSErrorMessageTest` checks the value is an `Error` with the right message and a string stack, and that a counting `globalThis.Error` replacement gets called exactly as often as `rt.createError` calls it, so it holds for native and default implementations. `DecoratorCreateErrorTest` checks that all seven `createXError` calls, and `JSError`, reach the wrapped runtime once through both decorators, and that `Around` runs once. `JSErrorDoesNotInfinitelyRecurse` and `CreateJSErrorPropagatesOOMExceptionTest` run through decorators that use the default `Runtime::createError`. This keeps the missing-constructor fallback and OOM propagation covered, since both tests depend on changing `globalThis.Error`. `APITests` (ASan + Debug, macOS arm64, `HERMESVM_EXCEPTION_ON_OOM=ON`): 362/362 pass, including SynthTrace and all three OOM tests. Built with `-O1` and `HERMES_ENABLE_WERROR=ON`; the existing GoogleTest `uninitialized-const-pointer` warning is demoted for AppleClang 21. ```sh cmake --build cmake-build-asan-oom --target APITests -j 8 cmake-build-asan-oom/unittests/API/APITests ``` Before the OOM test adaptation, `CreateJSErrorPropagatesOOMExceptionTest` fails because it throws `JSError` instead of `JSOutOfMemoryError`. It passes with the decorator. The earlier checks with the `jsi.cpp` and `decorator.h` changes reverted also made the new JSI tests fail. Reviewed By: javache Differential Revision: D124178378 Pulled By: lavenzg fbshipit-source-id: 33fa348abc52e21626f68d6509093313ab438d87
meta-codesync Bot
pushed a commit
to facebook/hermes
that referenced
this pull request
Oct 13, 2026
Summary: X-link: react/react-native#58961 `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. Pull Request resolved: #2203 Test Plan: Two new tests in testlib.cpp. `JSErrorMessageTest` checks the value is an `Error` with the right message and a string stack, and that a counting `globalThis.Error` replacement gets called exactly as often as `rt.createError` calls it, so it holds for native and default implementations. `DecoratorCreateErrorTest` checks that all seven `createXError` calls, and `JSError`, reach the wrapped runtime once through both decorators, and that `Around` runs once. `JSErrorDoesNotInfinitelyRecurse` and `CreateJSErrorPropagatesOOMExceptionTest` run through decorators that use the default `Runtime::createError`. This keeps the missing-constructor fallback and OOM propagation covered, since both tests depend on changing `globalThis.Error`. `APITests` (ASan + Debug, macOS arm64, `HERMESVM_EXCEPTION_ON_OOM=ON`): 362/362 pass, including SynthTrace and all three OOM tests. Built with `-O1` and `HERMES_ENABLE_WERROR=ON`; the existing GoogleTest `uninitialized-const-pointer` warning is demoted for AppleClang 21. ```sh cmake --build cmake-build-asan-oom --target APITests -j 8 cmake-build-asan-oom/unittests/API/APITests ``` Before the OOM test adaptation, `CreateJSErrorPropagatesOOMExceptionTest` fails because it throws `JSError` instead of `JSOutOfMemoryError`. It passes with the decorator. The earlier checks with the `jsi.cpp` and `decorator.h` changes reverted also made the new JSI tests fail. Reviewed By: javache Differential Revision: D124178378 Pulled By: lavenzg fbshipit-source-id: 33fa348abc52e21626f68d6509093313ab438d87
meta-codesync Bot
pushed a commit
to facebook/hermes
that referenced
this pull request
Oct 13, 2026
Summary: X-link: react/react-native#58961 `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. Pull Request resolved: #2203 Test Plan: Two new tests in testlib.cpp. `JSErrorMessageTest` checks the value is an `Error` with the right message and a string stack, and that a counting `globalThis.Error` replacement gets called exactly as often as `rt.createError` calls it, so it holds for native and default implementations. `DecoratorCreateErrorTest` checks that all seven `createXError` calls, and `JSError`, reach the wrapped runtime once through both decorators, and that `Around` runs once. `JSErrorDoesNotInfinitelyRecurse` and `CreateJSErrorPropagatesOOMExceptionTest` run through decorators that use the default `Runtime::createError`. This keeps the missing-constructor fallback and OOM propagation covered, since both tests depend on changing `globalThis.Error`. `APITests` (ASan + Debug, macOS arm64, `HERMESVM_EXCEPTION_ON_OOM=ON`): 362/362 pass, including SynthTrace and all three OOM tests. Built with `-O1` and `HERMES_ENABLE_WERROR=ON`; the existing GoogleTest `uninitialized-const-pointer` warning is demoted for AppleClang 21. ```sh cmake --build cmake-build-asan-oom --target APITests -j 8 cmake-build-asan-oom/unittests/API/APITests ``` Before the OOM test adaptation, `CreateJSErrorPropagatesOOMExceptionTest` fails because it throws `JSError` instead of `JSOutOfMemoryError`. It passes with the decorator. The earlier checks with the `jsi.cpp` and `decorator.h` changes reverted also made the new JSI tests fail. Reviewed By: javache Differential Revision: D124178378 Pulled By: lavenzg fbshipit-source-id: 33fa348abc52e21626f68d6509093313ab438d87
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
Test Plan:
Two new tests in testlib.cpp.
JSErrorMessageTestchecks the value is anErrorwith the right message and a string stack, and that a countingglobalThis.Errorreplacement gets called exactly as often asrt.createErrorcalls it, so it holds for native and default implementations.DecoratorCreateErrorTestchecks that all sevencreateXErrorcalls, andJSError, reach the wrapped runtime once through both decorators, and thatAroundruns once.JSErrorDoesNotInfinitelyRecurseandCreateJSErrorPropagatesOOMExceptionTestrun through decorators that use the defaultRuntime::createError. This keeps the missing-constructor fallback and OOM propagation covered, since both tests depend on changingglobalThis.Error.APITests(ASan + Debug, macOS arm64,HERMESVM_EXCEPTION_ON_OOM=ON): 362/362 pass, including SynthTrace and all three OOM tests. Built with-O1andHERMES_ENABLE_WERROR=ON; the existing GoogleTestuninitialized-const-pointerwarning is demoted for AppleClang 21.Before the OOM test adaptation,
CreateJSErrorPropagatesOOMExceptionTestfails because it throwsJSErrorinstead ofJSOutOfMemoryError. It passes with the decorator. The earlier checks with thejsi.cppanddecorator.hchanges reverted also made the new JSI tests fail.Reviewed By: javache
Differential Revision: D124178378
Pulled By: lavenzg