Skip to content

Commit 1ab0fcd

Browse files
committed
avoid event spamming
1 parent 2a66e02 commit 1ab0fcd

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rescript

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var bsconfig = "bsconfig.json";
1515
var bsb_exe = path.join(__dirname, process.platform, "rescript.exe");
1616

1717
var LAST_BUILD_START = 0;
18+
var LAST_FIRED_EVENT = 0;
1819
/**
1920
* @type {[string,string][]}
2021
*/
@@ -502,7 +503,7 @@ if (
502503
var event_time = +Date.now();
503504
var time_diff = event_time - LAST_BUILD_START;
504505
dlog(`Since last build : ${time_diff}`);
505-
if (time_diff < 5) {
506+
if (time_diff < 5 || event_time - LAST_FIRED_EVENT < 5) {
506507
// for 5ms, we could think that the ninja not get
507508
// kicked yet, so there is really no need
508509
// to send more events here
@@ -512,6 +513,7 @@ if (
512513
// save the event loop call `setImmediate`
513514
return;
514515
}
516+
LAST_FIRED_EVENT = event_time;
515517
if (validEvent(event, reason)) {
516518
dlog(`Event ${event} ${reason}`);
517519
reasons_to_rebuild.push([event, reason]);

0 commit comments

Comments
 (0)