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.
Problem
With a priority
postDelayof 300 ms, a task enqueued immediately afterawaiting 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,
awaitit, immediately enqueue a same-priority task, and assert it doesn't start beforepostDelayelapses. 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.