Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setTimeout runs inconsistently #653

Closed
klirix opened this issue Jul 12, 2022 · 1 comment
Closed

setTimeout runs inconsistently #653

klirix opened this issue Jul 12, 2022 · 1 comment
Labels
bug Something isn't working needs repro Needs an example to reproduce

Comments

@klirix
Copy link

klirix commented Jul 12, 2022

Version

0.1.2

Platform

Linux 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

What steps will reproduce the bug?

Bun.serve({
  fetch(this, request) {
    const time = Date.now();
    setTimeout(() => {
      Bun.write(Bun.stdout, `Resolved in ${Date.now() - time} \n`);
    }, 1000);
    return new Response("OK");
  },
  port: 3005,
});

How often does it reproduce? Is there a required condition?

This example reproduces consistently

What is the expected behavior?

Resolved in 1000 
Resolved in 1000 
Resolved in 1000 
Resolved in 1000 
Resolved in 1000 

What do you see instead?

When requests are launched via scripts, or by hand in rapid succession

Resolved in 1001 
Resolved in 586 
Resolved in 66 
Resolved in 1000 
Resolved in 1001 

Additional information

In a more complex cases I noticed that setTimeouts may resolve instantly or not resolve at all, instead of set period of ms. If I manage to reduce the repro to manageable format I will add it in a comment. From what I noticed the issue only appears when setTimeout is used with Bun server

@klirix klirix added bug Something isn't working needs repro Needs an example to reproduce labels Jul 12, 2022
@Jarred-Sumner
Copy link
Collaborator

Duplicate of #490

@Jarred-Sumner Jarred-Sumner marked this as a duplicate of #490 Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs repro Needs an example to reproduce
Projects
None yet
Development

No branches or pull requests

2 participants