Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions packages/react-native/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ let reactCxxReact = RNTarget(
path: "ReactCommon/cxxreact",
searchPaths: [CallInvokerPath],
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .logger, .reactDebug, .reactJsInspector]
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .logger, .reactDebug, .reactJsErrorHandler, .reactJsInspector]
)

/// React-jsitooling.podspec
Expand Down Expand Up @@ -268,15 +268,7 @@ let reactTurboModuleBridging = RNTarget(
name: .reactTurboModuleBridging,
path: "ReactCommon/react/bridging",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .reactPerfLogger, .reactCxxReact, .jsi, .logger]
)

/// React-jserrorhandler.podspec
let reactJsErrorHandler = RNTarget(
name: .reactJsErrorHandler,
path: "ReactCommon/jserrorhandler",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .jsi, .reactCxxReact, .reactFeatureFlags, .reactDebug, .reactTurboModuleBridging]
dependencies: [.reactNativeDependencies, .reactPerfLogger, .jsi, .logger]
)

/// React-graphicsApple
Expand Down Expand Up @@ -307,7 +299,7 @@ let reactTurboModuleCore = RNTarget(
"ReactCommon/react/nativemodule/core/platform/ios",
],
excludedPaths: ["platform/android", "iostests"],
dependencies: [.reactNativeDependencies, .reactDebug, .reactFeatureFlags, .reactUtils, .reactPerfLogger, .reactCxxReact, .reactTurboModuleBridging, .yoga, .reactRuntimeExecutor]
dependencies: [.reactNativeDependencies, .reactDebug, .reactJsErrorHandler, .reactFeatureFlags, .reactUtils, .reactPerfLogger, .reactCxxReact, .reactTurboModuleBridging, .yoga, .reactRuntimeExecutor]
)

/// React-defaultsnativemodule.podspec
Expand Down Expand Up @@ -396,6 +388,14 @@ let reactCoreModules = RNTarget(
dependencies: [.reactNativeDependencies, .jsi, .yoga, .reactTurboModuleCore, .reactFeatureFlags]
)

/// React-jserrorhandler.podspec
let reactJsErrorHandler = RNTarget(
name: .reactJsErrorHandler,
path: "ReactCommon/jserrorhandler",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .jsi, .reactFeatureFlags, .reactDebug, .reactTurboModuleBridging]
)

/// React-runtimeCore.podspec
/// React-runtimeHermes.podspec
let reactRuntime = RNTarget(
Expand Down
5 changes: 1 addition & 4 deletions packages/react-native/ReactCommon/ReactCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Pod::Spec.new do |s|
s.subspec "turbomodule" do |ss|
ss.dependency "React-callinvoker", version
ss.dependency "React-perflogger", version
ss.dependency "React-cxxreact", version
ss.dependency "React-jsi", version
ss.dependency "React-logger", version
if use_hermes()
Expand All @@ -56,14 +55,12 @@ Pod::Spec.new do |s|
sss.exclude_files = "react/bridging/tests"
sss.header_dir = "react/bridging"
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
if use_hermes()
sss.dependency "hermes-engine"
end
end

ss.subspec "core" do |sss|
sss.source_files = podspec_sources("react/nativemodule/core/ReactCommon/**/*.{cpp,h}", "react/nativemodule/core/ReactCommon/**/*.h")
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_featureflags.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\"" }
sss.dependency "React-cxxreact", version
sss.dependency "React-debug", version
sss.dependency "React-featureflags", version
sss.dependency "React-utils", version
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/ReactCommon/cxxreact/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_link_libraries(react_cxxreact
callinvoker
folly_runtime
glog
jserrorhandler
jsi
jsinspector
logger
Expand Down
34 changes: 2 additions & 32 deletions packages/react-native/ReactCommon/cxxreact/ErrorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,6 @@

#pragma once

#include <jsi/jsi.h>
#warning Deprecated: use <jserrorhandler/ErrorUtils.h> instead.

namespace facebook::react {

inline static void handleJSError(jsi::Runtime &runtime, const jsi::JSError &error, bool isFatal)
{
auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils");
if (errorUtils.isUndefined() || !errorUtils.isObject() ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportFatalError") ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportError")) {
// ErrorUtils was not set up. This probably means the bundle didn't
// load properly.
throw jsi::JSError(
runtime,
"ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " +
error.getMessage(),
error.getStack());
}

// TODO(janzer): Rewrite this function to return the processed error
// instead of just reporting it through the native module
if (isFatal) {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(runtime, "reportFatalError");

func.call(runtime, error.value());
} else {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(runtime, "reportError");

func.call(runtime, error.value());
}
}

} // namespace facebook::react
#include <jserrorhandler/ErrorUtils.h>
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/cxxreact/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#ifndef RCT_REMOVE_LEGACY_ARCH

#include "ErrorUtils.h"
#include <jserrorhandler/ErrorUtils.h>
#include "JSBigString.h"
#include "JSBundleType.h"
#include "JSExecutor.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <jsi/jsi.h>
#include <reactperflogger/BridgeNativeModulePerfLogger.h>

#include "ErrorUtils.h"
#include <jserrorhandler/ErrorUtils.h>
#include "Instance.h"
#include "JSBigString.h"
#include "MessageQueueThread.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Pod::Spec.new do |s|
s.dependency "React-callinvoker", version
add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
s.dependency "React-perflogger", version
s.dependency "React-jserrorhandler", version
s.dependency "React-jsi", version
s.dependency "React-logger", version
s.dependency "React-debug", version
Expand Down
42 changes: 42 additions & 0 deletions packages/react-native/ReactCommon/jserrorhandler/ErrorUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#include "ErrorUtils.h"

namespace facebook::react {

void handleJSError(
jsi::Runtime& runtime,
const jsi::JSError& error,
bool isFatal) {
auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils");
if (errorUtils.isUndefined() || !errorUtils.isObject() ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportFatalError") ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportError")) {
// ErrorUtils was not set up. This probably means the bundle didn't
// load properly.
throw jsi::JSError(
runtime,
"ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " +
error.getMessage(),
error.getStack());
}

// TODO(janzer): Rewrite this function to return the processed error
// instead of just reporting it through the native module
if (isFatal) {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(
runtime, "reportFatalError");
func.call(runtime, error.value());
} else {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(
runtime, "reportError");
func.call(runtime, error.value());
}
}

} // namespace facebook::react
16 changes: 16 additions & 0 deletions packages/react-native/ReactCommon/jserrorhandler/ErrorUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

#pragma once

#include <jsi/jsi.h>

namespace facebook::react {

void handleJSError(jsi::Runtime &runtime, const jsi::JSError &error, bool isFatal);

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

#include "JsErrorHandler.h"
#include <cxxreact/ErrorUtils.h>
#include <glog/logging.h>
#include <react/bridging/Bridging.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <ostream>
#include <string>
#include "ErrorUtils.h"
#include "StackTraceParser.h"

using namespace facebook;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.source = source
s.header_dir = "jserrorhandler"
s.source_files = podspec_sources(["JsErrorHandler.{cpp,h}", "StackTraceParser.{cpp,h}"], ["JsErrorHandler.h", "StackTraceParser.h"])
s.source_files = podspec_sources(["ErrorUtils.{cpp,h}", "JsErrorHandler.{cpp,h}", "StackTraceParser.{cpp,h}"], ["ErrorUtils.h", "JsErrorHandler.h", "StackTraceParser.h"])
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\""
}

resolve_use_frameworks(s, header_mappings_dir: '../', module_name: "React_jserrorhandler")

s.dependency "React-jsi"
s.dependency "React-cxxreact"
s.dependency "ReactCommon/turbomodule/bridging"
# TODO: this is a header-only dependency, but would otherwise pull in all of ReactCommon
# s.dependency "ReactCommon/turbomodule/bridging"
add_dependency(s, "React-featureflags")
add_dependency(s, "React-debug")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#include "jsireact/JSIExecutor.h"

#include <cxxreact/ErrorUtils.h>
#include <cxxreact/JSBigString.h>
#include <cxxreact/ModuleRegistry.h>
#include <cxxreact/ReactMarker.h>
#include <cxxreact/TraceSection.h>
#include <folly/json.h>
#include <glog/logging.h>
#include <jserrorhandler/ErrorUtils.h>
#include <jsi/JSIDynamic.h>
#include <jsi/instrumentation.h>
#include <reactperflogger/BridgeNativeModulePerfLogger.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target_include_directories(react_renderer_runtimescheduler PUBLIC ${REACT_COMMON

target_link_libraries(react_renderer_runtimescheduler
callinvoker
jserrorhandler
jsi
react_debug
react_performance_timeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "RuntimeScheduler_Legacy.h"
#endif

#include <cxxreact/ErrorUtils.h>
#include <cxxreact/TraceSection.h>
#include <jserrorhandler/ErrorUtils.h>
#ifndef RCT_REMOVE_LEGACY_ARCH
#include <react/featureflags/ReactNativeFeatureFlags.h>
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
#include "ReactInstance.h"

#include <ReactCommon/RuntimeExecutor.h>
#include <cxxreact/ErrorUtils.h>
#include <cxxreact/JSBigString.h>
#include <cxxreact/JSExecutor.h>
#include <cxxreact/ReactMarker.h>
#include <cxxreact/TraceSection.h>
#include <glog/logging.h>
#include <jserrorhandler/ErrorUtils.h>
#include <jsi/JSIDynamic.h>
#include <jsi/hermes-interfaces.h>
#include <jsi/instrumentation.h>
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAndroidDebugCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
void facebook::react::parseProcessedFilter(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::FilterFunction>& result);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAndroidNewarchCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
void facebook::react::parseProcessedFilter(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::FilterFunction>& result);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAndroidReleaseCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
void facebook::react::parseProcessedFilter(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::FilterFunction>& result);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleDebugCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -3964,6 +3964,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::installLegacyUIManagerConstantsProviderBinding(facebook::jsi::Runtime& runtime);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleNewarchCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -3949,6 +3949,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::installLegacyUIManagerConstantsProviderBinding(facebook::jsi::Runtime& runtime);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactAppleReleaseCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -3964,6 +3964,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::installLegacyUIManagerConstantsProviderBinding(facebook::jsi::Runtime& runtime);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
Expand Down
1 change: 1 addition & 0 deletions scripts/cxx-api/api-snapshots/ReactCommonDebugCxx.api
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ void facebook::react::fromRawValue(const facebook::react::PropsParserContext&, c
void facebook::react::fromRawValueShared(const facebook::react::ContextContainer& contextContainer, int32_t surfaceId, const facebook::react::RawValue& value, facebook::react::SharedColor& result, facebook::react::parsePlatformColorFn parsePlatformColor);
void facebook::react::fromString(const std::string& string, facebook::react::AccessibilityTraits& result);
void facebook::react::g_setNativeAnimatedNowTimestampFunction(facebook::react::TimePointFunction nowFunction);
void facebook::react::handleJSError(facebook::jsi::Runtime& runtime, const facebook::jsi::JSError& error, bool isFatal);
void facebook::react::parseProcessedBackgroundImage(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BackgroundImage>& result);
void facebook::react::parseProcessedBoxShadow(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::BoxShadow>& result);
void facebook::react::parseProcessedFilter(const facebook::react::PropsParserContext& context, const facebook::react::RawValue& value, std::vector<facebook::react::FilterFunction>& result);
Expand Down
Loading
Loading