diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 08db1eddaad487..bd790467034896 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -199,7 +199,9 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName if (expectErrorBlock) { RCTAssert(expectErrorBlock(errors[0]), @"Expected an error but the first one was missing or did not match."); } else { - RCTAssert(errors == nil, @"RedBox errors: %@", errors); + // [TODO(OSS Candidate ISS#2710739): xcpretty formats the test failure output to show only one line of the assert string followed by a snippet of source code including the assert statement and the lines just before and after. + // Convert the `errors` array into a single line string delimited by \n so that CI logs contain meaningful information. + RCTAssert(errors == nil, @"RedBox errors: %@", [[errors valueForKey:@"description"] componentsJoinedByString:@"\\n"]); // ]TODO(OSS Candidate ISS#2710739) RCTAssert(testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds); RCTAssert(testModule.status == RCTTestStatusPassed, @"Test failed"); } diff --git a/Libraries/WebSocket/WebSocket.js b/Libraries/WebSocket/WebSocket.js index a954175fc0ce1a..2d6cd5c4c98f6f 100644 --- a/Libraries/WebSocket/WebSocket.js +++ b/Libraries/WebSocket/WebSocket.js @@ -224,7 +224,11 @@ class WebSocket extends EventTarget(...WEBSOCKET_EVENTS) { } _close(code?: number, reason?: string): void { - if (Platform.OS === 'android' || Platform.OS === 'win32' || Platform.OS == 'windesktop') { + if ( + Platform.OS === 'android' || + Platform.OS === 'win32' || + Platform.OS === 'windesktop' + ) { // See https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent const statusCode = typeof code === 'number' ? code : CLOSE_NORMAL; const closeReason = typeof reason === 'string' ? reason : ''; diff --git a/RNTester/js/RNTesterApp.ios.js b/RNTester/js/RNTesterApp.ios.js index 7d5b1a1b23910a..e5697e7d8b3458 100644 --- a/RNTester/js/RNTesterApp.ios.js +++ b/RNTester/js/RNTesterApp.ios.js @@ -58,13 +58,21 @@ const Header = ({onBack, title}: {onBack?: () => mixed, title: string}) => ( ); class RNTesterApp extends React.Component { + _mounted: boolean; // TODO(OSS Candidate ISS#2710739) + UNSAFE_componentWillMount() { BackHandler.addEventListener('hardwareBackPress', this._handleBack); } componentDidMount() { + this._mounted = true; // TODO(OSS Candidate ISS#2710739) Linking.getInitialURL().then(url => { AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => { + // [TODO(OSS Candidate ISS#2710739) + if (!this._mounted) { + return; + } + // ]TODO(OSS Candidate ISS#2710739) const exampleAction = URIActionMap( this.props.exampleFromAppetizeParams, ); @@ -89,6 +97,12 @@ class RNTesterApp extends React.Component { }); } + // [TODO(OSS Candidate ISS#2710739) + componentWillUnmount() { + this._mounted = false; + } + // ]TODO(OSS Candidate ISS#2710739) + _handleBack = () => { this._handleAction(RNTesterActions.Back()); }; diff --git a/RNTester/js/RNTesterApp.macos.js b/RNTester/js/RNTesterApp.macos.js index c5af64a394511c..440b7d3281c427 100644 --- a/RNTester/js/RNTesterApp.macos.js +++ b/RNTester/js/RNTesterApp.macos.js @@ -60,13 +60,21 @@ const Header = ({onBack, title}: {onBack?: () => mixed, title: string}) => ( ); class RNTesterApp extends React.Component { + _mounted: boolean; // TODO(OSS Candidate ISS#2710739) + UNSAFE_componentWillMount() { // BackHandler.addEventListener('hardwareBackPress', this._handleBack); } componentDidMount() { + this._mounted = true; // TODO(OSS Candidate ISS#2710739) Linking.getInitialURL().then(url => { AsyncStorage.getItem(APP_STATE_KEY, (err, storedString) => { + // [TODO(OSS Candidate ISS#2710739) + if (!this._mounted) { + return; + } + // ]TODO(OSS Candidate ISS#2710739) const exampleAction = URIActionMap( this.props.exampleFromAppetizeParams, ); @@ -91,6 +99,12 @@ class RNTesterApp extends React.Component { }); } + // [TODO(OSS Candidate ISS#2710739) + componentWillUnmount() { + this._mounted = false; + } + // ]TODO(OSS Candidate ISS#2710739) + _handleBack = () => { this._handleAction(RNTesterActions.Back()); };