fixed Array.prototype.push.apply will throw Maximum call stack size exceeded (#119)

* fixed Array.prototype.push.apply will throw Maximum call stack size exceeded

* fixed review comment
This commit is contained in:
Hoan Luu Huu
2025-11-11 19:44:18 +07:00
committed by GitHub
parent 56df3a6b34
commit 9c6134d5dc
2 changed files with 9 additions and 3 deletions

View File

@@ -223,11 +223,17 @@ const updateCarrierRegbots = async(logger, srf) => {
debug('updateCarrierRegbots: got new or changed carriers');
logger.info({gws}, 'updateCarrierRegbots: got new or changed carriers');
// Clear and repopulate arrays in chunks to avoid argument limit
carriers.length = 0;
Array.prototype.push.apply(carriers, cs);
for (let i = 0; i < cs.length; i += 1000) {
Array.prototype.push.apply(carriers, cs.slice(i, i + 1000));
}
gateways.length = 0;
Array.prototype.push.apply(gateways, gws);
for (let i = 0; i < gws.length; i += 1000) {
Array.prototype.push.apply(gateways, gws.slice(i, i + 1000));
}
// stop / kill existing regbots
regbots.forEach((rb) => rb.stop(srf));

2
package-lock.json generated
View File

@@ -31,7 +31,7 @@
"tape": "^5.7.5"
},
"engines": {
"node": ">= 18.0.0"
"node": ">= 20.0.0"
}
},
"node_modules/@ampproject/remapping": {