Skip to content

Commit 4aad4dd

Browse files
committed
refactor: improve timeout handling in Iterable class to prevent process from hanging
1 parent 46d1949 commit 4aad4dd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/core/classes/Iterable.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,9 +948,11 @@ export class Iterable {
948948

949949
if (Platform.OS === 'android') {
950950
//Give enough time for Activity to wake up.
951-
setTimeout(() => {
951+
const timeoutId = setTimeout(() => {
952952
callUrlHandler(url, context);
953953
}, 1000);
954+
// Use unref() to prevent the timeout from keeping the process alive
955+
timeoutId.unref();
954956
} else {
955957
callUrlHandler(url, context);
956958
}
@@ -995,7 +997,7 @@ export class Iterable {
995997
(promiseResult as IterableAuthResponse).authToken
996998
);
997999

998-
setTimeout(() => {
1000+
const timeoutId = setTimeout(() => {
9991001
if (
10001002
authResponseCallback === IterableAuthResponseResult.SUCCESS
10011003
) {
@@ -1014,6 +1016,8 @@ export class Iterable {
10141016
);
10151017
}
10161018
}, 1000);
1019+
// Use unref() to prevent the timeout from keeping the process alive
1020+
timeoutId.unref();
10171021
} else if (typeof promiseResult === typeof '') {
10181022
//If promise only returns string
10191023
RNIterableAPI.passAlongAuthToken(promiseResult as string);

0 commit comments

Comments
 (0)