Skip to content

Commit 75e85e2

Browse files
committed
fix: crash screen Try Again does nothing in production
Wire the Try Again button to reloadAppAsync so the app reloads in production builds instead of calling DevSettings.reload(), which only works in development. Fixes #26751
1 parent a98213c commit 75e85e2

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

app/components/Views/ErrorBoundary/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
Alert,
88
Modal,
99
KeyboardAvoidingView,
10-
DevSettings,
1110
TextInput,
1211
ScrollView,
1312
} from 'react-native';
1413
import PropTypes from 'prop-types';
14+
import { reloadAppAsync } from 'expo';
1515
import { lastEventId as getLatestSentryId } from '@sentry/react-native';
1616
import {
1717
captureSentryFeedback,
@@ -153,7 +153,11 @@ export const Fallback = (props) => {
153153
const handleContactSupport = () =>
154154
Linking.openURL(AppConstants.REVIEW_PROMPT.SUPPORT);
155155

156-
const handleTryAgain = () => DevSettings.reload();
156+
const handleTryAgain = () => {
157+
reloadAppAsync('Error boundary Try again').catch((error) => {
158+
Logger.log(error, 'Error reloading app after Try again pressed');
159+
});
160+
};
157161

158162
const handleSubmit = () => {
159163
toggleModal();
@@ -449,10 +453,6 @@ class ErrorBoundary extends Component {
449453
});
450454
}
451455

452-
resetError = () => {
453-
this.setState({ error: null });
454-
};
455-
456456
showExportSeedphrase = () => {
457457
this.setState({ backupSeedphrase: true });
458458
};
@@ -509,7 +509,6 @@ class ErrorBoundary extends Component {
509509
? this.renderWithSafeArea(
510510
<Fallback
511511
errorMessage={this.getErrorMessage()}
512-
resetError={this.resetError}
513512
showExportSeedphrase={this.showExportSeedphrase}
514513
copyErrorToClipboard={this.copyErrorToClipboard}
515514
openTicket={this.openTicket}

app/components/Views/ErrorBoundary/index.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ import {
1010
import Logger from '../../../util/Logger';
1111
import { strings } from '../../../../locales/i18n';
1212
import { analytics } from '../../../util/analytics/analytics';
13+
import { reloadAppAsync } from 'expo';
14+
15+
jest.mock('expo', () => ({
16+
reloadAppAsync: jest.fn().mockResolvedValue(undefined),
17+
}));
1318

1419
jest.mock('../../../util/analytics/analytics', () => ({
1520
analytics: {
@@ -166,6 +171,20 @@ describe('ErrorBoundary', () => {
166171
expect(mockProps.copyErrorToClipboard).toHaveBeenCalledTimes(1);
167172
});
168173

174+
it('calls reloadAppAsync when Try again is pressed', async () => {
175+
const { getByText } = renderWithProvider(<Fallback {...mockProps} />, {
176+
state: initialState,
177+
});
178+
179+
const tryAgainButton = getByText('Try again');
180+
await act(async () => {
181+
fireEvent.press(tryAgainButton);
182+
});
183+
184+
expect(reloadAppAsync).toHaveBeenCalledTimes(1);
185+
expect(reloadAppAsync).toHaveBeenCalledWith('Error boundary Try again');
186+
});
187+
169188
it('calls showExportSeedphrase when save seedphrase link is pressed', async () => {
170189
const { getAllByText } = renderWithProvider(<Fallback {...mockProps} />, {
171190
state: initialState,

0 commit comments

Comments
 (0)