Skip to content

Creating a timeout for a promise #29

@deblauwetom

Description

@deblauwetom

Hello,

I'm trying to use libq to create a timeout for a function that may take too long to complete. So the case is that if the function completes in time, say 5 seconds, it's ok, otherwise I want the promise to be rejected. So I created a shared promise, with one branch running the function, and another running a .delay(5s).then(...). But now I want to "cancel" the delay task if my function was completed within 5s. What would be the preferred way for this?

Best regards,
Tom,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions