Skip to content

Commit a6b8494

Browse files
Fix a potential bug in the stop method.
1 parent cc3f0e9 commit a6b8494

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

android/src/main/java/com/reactnativestripesdk/utils/KeepJsAwakeTask.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,14 @@ internal class KeepJsAwakeTask(
3333
fun stop() {
3434
val taskId = taskId ?: return
3535
val headlessJsTaskContext = HeadlessJsTaskContext.getInstance(context)
36-
headlessJsTaskContext.finishTask(taskId)
37-
this.taskId = null
36+
37+
try {
38+
headlessJsTaskContext.finishTask(taskId)
39+
} catch (e: AssertionError) {
40+
// Ignore if task already finished
41+
// Log.w("KeepJsAwakeTask", "Tried to stop a non-existent task (id=$taskId)")
42+
} finally {
43+
this.taskId = null
44+
}
3845
}
3946
}

0 commit comments

Comments
 (0)