1
0
Fork 0
forked from svrjs/svrjs

Improved Bun workaround

This commit is contained in:
Dorian Niemiec 2023-09-08 20:08:46 +02:00
parent 3edbc80e7d
commit 1e2d61ff64
2 changed files with 24 additions and 22 deletions

View file

@ -3,7 +3,7 @@
"port": 80,
"pubport": 80,
"page404": "404.html",
"timestamp": 1694195890852,
"timestamp": 1694196507492,
"blacklist": [],
"nonStandardCodes": [],
"enableCompression": true,
@ -102,4 +102,4 @@
"errorPages": [],
"useWebRootServerSideScript": true,
"exposeModsInErrorPages": true
}
}

42
svr.js
View file

@ -223,28 +223,31 @@ if (!singlethreaded) {
function checkSendImplementation(worker) {
var sendImplemented = true;
if (!worker.send) {
sendImplemented = false;
}
var oldLog = console.log;
console.log = function (a,b,c,d,e,f) {
if(a == "ChildProcess.prototype.send() - Sorry! Not implemented yet") {
throw new Error("NOT IMPLEMENTED");
} else {
oldLog(a,b,c,d,e,f);
}
};
try {
worker.send(undefined);
} catch (err) {
if (err.message === "NOT IMPLEMENTED") {
if (!(process.versions && process.versions.bun && process.versions.bun[0] != "0")) {
if (!worker.send) {
sendImplemented = false;
}
}
console.log = oldLog;
var oldLog = console.log;
console.log = function (a,b,c,d,e,f) {
if(a == "ChildProcess.prototype.send() - Sorry! Not implemented yet") {
throw new Error("NOT IMPLEMENTED");
} else {
oldLog(a,b,c,d,e,f);
}
};
try {
worker.send(undefined);
} catch (err) {
if (err.message === "NOT IMPLEMENTED") {
sendImplemented = false;
}
console.log(err);
}
console.log = oldLog;
}
return sendImplemented;
}
@ -5083,7 +5086,6 @@ function start(init) {
}
if (!cluster.isPrimary && cluster.isPrimary !== undefined) {
process.on("message", function (line) {
if(line === undefined) return; // Workaround for Bun 1.0.0
try {
if (line == "") {
// Does Nothing