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

Ubuntu 22.04 LTS minimal All callbacks do not work properly. #44138

Closed
sizkein opened this issue Aug 5, 2022 · 1 comment
Closed

Ubuntu 22.04 LTS minimal All callbacks do not work properly. #44138

sizkein opened this issue Aug 5, 2022 · 1 comment

Comments

@sizkein
Copy link

sizkein commented Aug 5, 2022

Version

v18.7.0

Platform

Linux scv 5.15.0-43-generic #46-Ubuntu SMP Tue Jul 12 10:30:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

If there is a while function outside, other callbacks do not work.

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

If there is a while function outside, other callbacks do not work.

What is the expected behavior?

There is no error and it just doesn't work.
The process is not terminated, just waiting

What do you see instead?

just waiting

var sleep = require('system-sleep');
var request = require('urllib-sync').request;

function start(){
	request('url');
}

if(process.argv[2]=='dev'){
	start();
}

while(1){
	if(new Date().getHours() > 1 && new Date().getHours() < 8){
		sleep(getRandomArbitrary(60000*10, 60000*30))
	}else{
		sleep(getRandomArbitrary(60000, 60000*5))
	}
	start();
}

function getRandomArbitrary(min, max) {
  return Math.round(Math.random() * (max - min) + min, 0);
}

Additional information

No response

@mscdex
Copy link
Contributor

mscdex commented Aug 5, 2022

You're probably blocking the main thread with your sleep(). Don't do that. Node utilizes an event loop, so if you block the main thread, none of those events can be processed.

@sizkein sizkein closed this as completed Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants