forked from svrjs/svrjs
Improved Bun workaround
This commit is contained in:
parent
3edbc80e7d
commit
1e2d61ff64
2 changed files with 24 additions and 22 deletions
|
@ -3,7 +3,7 @@
|
||||||
"port": 80,
|
"port": 80,
|
||||||
"pubport": 80,
|
"pubport": 80,
|
||||||
"page404": "404.html",
|
"page404": "404.html",
|
||||||
"timestamp": 1694195890852,
|
"timestamp": 1694196507492,
|
||||||
"blacklist": [],
|
"blacklist": [],
|
||||||
"nonStandardCodes": [],
|
"nonStandardCodes": [],
|
||||||
"enableCompression": true,
|
"enableCompression": true,
|
||||||
|
@ -102,4 +102,4 @@
|
||||||
"errorPages": [],
|
"errorPages": [],
|
||||||
"useWebRootServerSideScript": true,
|
"useWebRootServerSideScript": true,
|
||||||
"exposeModsInErrorPages": true
|
"exposeModsInErrorPages": true
|
||||||
}
|
}
|
42
svr.js
42
svr.js
|
@ -223,28 +223,31 @@ if (!singlethreaded) {
|
||||||
function checkSendImplementation(worker) {
|
function checkSendImplementation(worker) {
|
||||||
var sendImplemented = true;
|
var sendImplemented = true;
|
||||||
|
|
||||||
if (!worker.send) {
|
if (!(process.versions && process.versions.bun && process.versions.bun[0] != "0")) {
|
||||||
sendImplemented = false;
|
if (!worker.send) {
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
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;
|
return sendImplemented;
|
||||||
}
|
}
|
||||||
|
@ -5083,7 +5086,6 @@ function start(init) {
|
||||||
}
|
}
|
||||||
if (!cluster.isPrimary && cluster.isPrimary !== undefined) {
|
if (!cluster.isPrimary && cluster.isPrimary !== undefined) {
|
||||||
process.on("message", function (line) {
|
process.on("message", function (line) {
|
||||||
if(line === undefined) return; // Workaround for Bun 1.0.0
|
|
||||||
try {
|
try {
|
||||||
if (line == "") {
|
if (line == "") {
|
||||||
// Does Nothing
|
// Does Nothing
|
||||||
|
|
Reference in a new issue