Delete jobs when disconnecting from image servers

This commit is contained in:
TheEssem 2021-05-17 15:39:22 -05:00
parent 82ab3f672f
commit b748e54437
No known key found for this signature in database
GPG Key ID: A3F9F02129092FCA
1 changed files with 2 additions and 1 deletions

View File

@ -97,7 +97,7 @@ exports.connect = (server) => {
});
connection.once("close", () => {
for (const uuid of Object.keys(jobs)) {
if (jobs[uuid].addr === connection.remoteAddress) jobs[uuid].event.emit("error", new Error("Job ended prematurely due to a closed connection; please run your image job again"));
if (jobs[uuid].addr === connection.remoteAddress) jobs[uuid].event.emit("error", "Job ended prematurely due to a closed connection; please run your image job again");
}
});
this.connections.push(connection);
@ -111,6 +111,7 @@ exports.disconnect = async () => {
}
for (const uuid of Object.keys(jobs)) {
jobs[uuid].event.emit("error", "Job ended prematurely (not really an error; just run your image job again)");
delete jobs[uuid];
}
this.connections = [];
return;