Skip to content

Possible race: a task enqueued right after awaiting the previous one can skip the priority postDelay #52

Description

@Shinrai

Problem

With a priority postDelay of 300 ms, a task enqueued immediately after awaiting the previous task started 1 ms later, with no delay. Tasks already queued, or enqueued a few ms later, did get the delay. The likely cause is that the previous task's promise resolves before the queue records the completion time the delay is measured from. It was observed once, while verifying README examples (#50).

Fix

Write a deterministic test with fake timers: run a task, await it, immediately enqueue a same-priority task, and assert it doesn't start before postDelay elapses. If it fails, record the completion time and delay state before resolving the task's promise. If it can't be reproduced deterministically, document why and close.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreTouches core library / runtime source codepriority: mediumShould be addressed in the normal course of developmentstatus: implementedBuilt and deployed, but not yet fully tested/verifiedtype: bugSomething is broken or not behaving as expected

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions