-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Timers are not canceled after --hot
reload
#8963
Comments
We should probably cancel timers on |
--hot
reload
For anyone using --hot as of today, you can use a simple looping alternative: console.log(`Program started`, Date.now())
intervalFunction();
function intervalFunction()
{
console.log("Hello World !");
await new Promise(resolve => setTimeout(resolve, 1000))
return await intervalFunction();
} |
Update, it appears that the issue occurs on setInterval. /*
[DEBUG] Loading new schedule : _schedules/paidProductsDisabler with interval of 1000
[DEBUG] Controller Executed at 1708544326475
[2] Billing status: 1 | Days Left: 17.86 | Failed Days Left: null
[4] Billing status: 3 | Days Left: 17.87 | Failed Days Left: null
[DEBUG] Controller Executed at 1708544326479
[2] Billing status: 1 | Days Left: 17.86 | Failed Days Left: null
[4] Billing status: 3 | Days Left: 17.87 | Failed Days Left: null
[DEBUG] Controller Executed at 1708544326482
[2] Billing status: 1 | Days Left: 17.86 | Failed Days Left: null
[4] Billing status: 3 | Days Left: 17.87 | Failed Days Left: null
[DEBUG] Controller Executed at 1708544326485
[2] Billing status: 1 | Days Left: 17.86 | Failed Days Left: null
[4] Billing status: 3 | Days Left: 17.87 | Failed Days Left: null
One is supposed to arrive
*/
console.log(`Entering loading Schedules [Total: ${this.#schedules.length} schedules]`);
for (let schedule of this.#schedules)
{
console.log(`[DEBUG] Loading new schedule : ${schedule.controller} with interval of ${schedule.interval}`);
setTimeout(() => {
let res = new ResponseBuilder(this.#directory, "");
return res.loadController(schedule.controller, {
models: this.#models
}, res)
}, schedule.interval);
} |
Thank you, still there are some native or npm packages using interval e.g. @elysiajs/cron |
Well, the objective would be to resolve the conflicts linked to Bun --hot and Timers, I do not see how using cron resolves the issue by itself as it is a core Javascript feature that is "compromised" |
What version of Bun is running?
1.0.25+a8ff7be64
What platform is your computer?
Linux 5.4.0-29-generic x86_64 x86_64
What steps can reproduce the bug?
The error seem to be comming from bun --hot, this error seem to affect the native "setInterval" function.
On hot reload, the setInterval functions seem to be "dismissed", and they keep running like nothing happened.
Here is a simple code example
If you load this program with bun index.js, everything is fine, it will work.
Now, if you run bun --hot index.js, and then save a file inside the hot reload scope, the program will restart, but the previous intervals executions will remain.
2024-02-17.09-54-20.mp4
What is the expected behavior?
Said Up there
What do you see instead?
Said Up there
Additional information
No response
The text was updated successfully, but these errors were encountered: