Skip to content

Commit 3feed51

Browse files
authored
Clear Fantom's Metro shutdown timer once the server closes (#59710)
1 parent a59500e commit 3feed51

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎private/react-native-fantom/runner/global-setup/globalTeardown.js‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ async function stopMetroServer(metroServer: MetroServer): Promise<void> {
5555
metroServer.closeIdleConnections();
5656
}
5757

58+
let timeoutId;
5859
const timeout = new Promise<void>(resolve => {
59-
setTimeout(() => {
60+
timeoutId = setTimeout(() => {
6061
// $FlowFixMe[method-unbinding] Node 18.2+ API
6162
if (typeof metroServer.closeAllConnections === 'function') {
6263
/* $FlowFixMe[incompatible-type] Error exposed after fixing this typing
@@ -67,5 +68,9 @@ async function stopMetroServer(metroServer: MetroServer): Promise<void> {
6768
}, SHUTDOWN_TIMEOUT_MS);
6869
});
6970

70-
await Promise.race([closed, timeout]);
71+
try {
72+
await Promise.race([closed, timeout]);
73+
} finally {
74+
clearTimeout(timeoutId);
75+
}
7176
}

0 commit comments

Comments
 (0)