Skip to content

InteractionManager crash when cancelling promise task before it completes #16321

@jfaris

Description

@jfaris

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

react-native 0.47.2

Steps to Reproduce

  1. Schedule a long-running promise task with InteractionManager.runAfterInteractions
    const promise = InteractionManager.runAfterInteractions({
      gen: () => {
        // do a long fetch and return a promise
      }
    });
  1. After the task has started but before it is done, cancel the task
    promise.cancel()
  1. When the task completes TaskQueue will throw an exception
    TaskQueue: Error resolving Promise in task undefined: undefined is not an object (evaluating '_this2._queueStack[stackIdx].popable = true')

Expected Behavior

No error would be thrown. InteractionManager (TaskQueue) would ignore the completion of a cancelled task and start the next task.

Actual Behavior

Error was thrown from TaskQueue line 158:

iOS: TaskQueue: Error resolving Promise in task undefined: undefined is not an object (evaluating '_this2._queueStack[stackIdx].popable = true')

Android: TaskQueue: Error resolving Promise in task undefined: Attempted to assign to readonly property.

Reproducible Demo

https://snack.expo.io/HJivJZ33-

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: Author Provided ReproThis issue can be reproduced in Snack or an attached project.JavaScriptStaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions