Skip to content

Commit ed1a195

Browse files
committed
Retry on error
1 parent 7d90060 commit ed1a195

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/features/flows/nRF54L15_cloud/evaluate/TestCrash.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export default ({ vComIndex }: { vComIndex: number }) => {
3939
const crashReport = useAppSelector(getCrashReport);
4040
const [error, setError] = useState<string>();
4141

42-
const { reset, pause, time } = useStopwatch({
42+
const { reset, pause, start, time } = useStopwatch({
4343
autoStart: !crashReport,
4444
resolution: TIMEOUT_MS,
4545
});
@@ -67,6 +67,7 @@ export default ({ vComIndex }: { vComIndex: number }) => {
6767
fetchCrashBaseline(serialNumber, controller.signal)
6868
.then(b => dispatch(setCrashReportBaselineDate(b)))
6969
.catch(e => {
70+
pause();
7071
if ((e as Error).name === 'AbortError') {
7172
return;
7273
}
@@ -80,7 +81,6 @@ export default ({ vComIndex }: { vComIndex: number }) => {
8081
controller.signal,
8182
)
8283
.then(crash => {
83-
pause();
8484
dispatch(setCrashReport(crash));
8585
})
8686
.catch(e => {
@@ -89,6 +89,9 @@ export default ({ vComIndex }: { vComIndex: number }) => {
8989
}
9090
reportEvaluateError('Test crash', e, 'poll-crash');
9191
setError(describeError(e));
92+
})
93+
.finally(() => {
94+
pause();
9295
});
9396
}
9497

@@ -107,6 +110,12 @@ export default ({ vComIndex }: { vComIndex: number }) => {
107110
pause,
108111
]);
109112

113+
useEffect(() => {
114+
if (!error) {
115+
start(0);
116+
}
117+
}, [error, start]);
118+
110119
const preparingBaseline =
111120
deviceInfo.status === 'success' &&
112121
crashReportBaselineDate === undefined &&
@@ -252,10 +261,16 @@ export default ({ vComIndex }: { vComIndex: number }) => {
252261
/>
253262
)}
254263

255-
{deviceInfo.status === 'error' ? (
264+
{error || deviceInfo.status === 'error' ? (
256265
<Next
257266
label="Retry"
258-
onClick={() => dispatch(fetchDeviceInfo(vComIndex))}
267+
onClick={() => {
268+
if (error) {
269+
setError(undefined);
270+
} else {
271+
dispatch(fetchDeviceInfo(vComIndex));
272+
}
273+
}}
259274
/>
260275
) : (
261276
<Next

0 commit comments

Comments
 (0)