Skip to content

Commit 26fad51

Browse files
motiz88meta-codesync[bot]
authored andcommitted
Mark all errors as retryable (#56552)
Summary: Pull Request resolved: #56552 Adds `isRetryable` and `isCompileError` to C++ `ParsedError` and its iOS wrapper, for use in RedBox 2.0. **Currently all errors are assumed to be retryable under RedBox 2.0.** Changelog: [Internal] Differential Revision: D101357708
1 parent fc11cfc commit 26fad51

4 files changed

Lines changed: 10 additions & 0 deletions

File tree

packages/react-native/React/CoreModules/RCTRedBox2ErrorParser+Internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
@property (nonatomic, assign) NSInteger codeFrameRow;
2626
/// Column number in the source file
2727
@property (nonatomic, assign) NSInteger codeFrameColumn;
28+
/// Whether this is a compile-time error (syntax, transform, resolution) vs a runtime error
29+
@property (nonatomic, assign) BOOL isCompileError;
30+
/// Whether auto-retry is appropriate (compile errors, connectivity failures, etc.)
31+
@property (nonatomic, assign) BOOL isRetryable;
2832

2933
@end
3034

packages/react-native/React/CoreModules/RCTRedBox2ErrorParser.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
RCTRedBox2ErrorData *data = [[RCTRedBox2ErrorData alloc] init];
2121
data.title = [NSString stringWithUTF8String:parsed.title.c_str()];
2222
data.message = [NSString stringWithUTF8String:parsed.message.c_str()];
23+
data.isCompileError = parsed.isCompileError;
24+
data.isRetryable = parsed.isRetryable;
25+
2326
if (parsed.codeFrame.has_value()) {
2427
const auto &cf = *parsed.codeFrame;
2528
data.codeFrame = [NSString stringWithUTF8String:cf.content.c_str()];

packages/react-native/ReactCommon/react/debug/redbox/RedBoxErrorParser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ struct ParsedError {
2424
std::string message;
2525
std::optional<CodeFrame> codeFrame;
2626
bool isCompileError = false;
27+
bool isRetryable = true;
2728
};
2829

2930
/**

packages/react-native/ReactCommon/react/debug/redbox/tests/RedBoxErrorParserTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TEST(RedBoxErrorParserTest, ParsesBabelTransformError) {
2323
EXPECT_EQ(result.codeFrame->row, 10);
2424
EXPECT_EQ(result.codeFrame->column, 5);
2525
EXPECT_TRUE(result.isCompileError);
26+
EXPECT_TRUE(result.isRetryable);
2627
}
2728

2829
TEST(RedBoxErrorParserTest, ParsesMetroError) {
@@ -75,6 +76,7 @@ TEST(RedBoxErrorParserTest, DefaultsToUncaughtError) {
7576
EXPECT_EQ(result.message, "TypeError: undefined is not a function");
7677
EXPECT_FALSE(result.codeFrame.has_value());
7778
EXPECT_FALSE(result.isCompileError);
79+
EXPECT_TRUE(result.isRetryable);
7880
}
7981

8082
TEST(RedBoxErrorParserTest, UsesNameForTitle) {

0 commit comments

Comments
 (0)