1
0
Fork 0
forked from svrjs/svrjs

Fix "Can't read property 1 of undefined" error. Also unify crash handlers.

This commit is contained in:
Dorian Niemiec 2024-04-02 11:21:04 +02:00
parent 1ef32bfe1d
commit ee568d252e

18
svr.js
View file

@ -3675,7 +3675,9 @@ if (!cluster.isPrimary) {
if (filelist[i].name[0] !== ".") { if (filelist[i].name[0] !== ".") {
var estats = filelist[i].stats; var estats = filelist[i].stats;
var ename = filelist[i].name; var ename = filelist[i].name;
var eext = ename.match(/\.([^.]+)$/)[1]; var eext = ename.match(/\.([^.]+)$/);
if (eext) eext = eext[1];
else eext = "";
var emime = eext ? mime.contentType(eext) : false; var emime = eext ? mime.contentType(eext) : false;
if (filelist[i].errored) { if (filelist[i].errored) {
directoryListingRows.push( directoryListingRows.push(
@ -5719,19 +5721,15 @@ if (cluster.isPrimary || cluster.isPrimary === undefined) {
}); });
} else { } else {
// Crash handler // Crash handler
process.on("uncaughtException", function (err) { function crashHandler(err) {
serverconsole.locerrmessage("SVR.JS worker just crashed!!!");
serverconsole.locerrmessage("Stack:");
serverconsole.locerrmessage(generateErrorStack(err));
process.exit(err.errno);
});
process.on("unhandledRejection", function (err) {
serverconsole.locerrmessage("SVR.JS worker just crashed!!!"); serverconsole.locerrmessage("SVR.JS worker just crashed!!!");
serverconsole.locerrmessage("Stack:"); serverconsole.locerrmessage("Stack:");
serverconsole.locerrmessage(err.stack ? generateErrorStack(err) : String(err)); serverconsole.locerrmessage(err.stack ? generateErrorStack(err) : String(err));
process.exit(err.errno); process.exit(err.errno);
}); }
process.on("uncaughtException", crashHandler);
process.on("unhandledRejection", crashHandler);
// Warning handler // Warning handler
process.on("warning", function (warning) { process.on("warning", function (warning) {