Delete jobs when disconnecting from image servers
This commit is contained in:
		
							parent
							
								
									82ab3f672f
								
							
						
					
					
						commit
						b748e54437
					
				
					 1 changed files with 2 additions and 1 deletions
				
			
		| 
						 | 
					@ -97,7 +97,7 @@ exports.connect = (server) => {
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    connection.once("close", () => {
 | 
					    connection.once("close", () => {
 | 
				
			||||||
      for (const uuid of Object.keys(jobs)) {
 | 
					      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);
 | 
					    this.connections.push(connection);
 | 
				
			||||||
| 
						 | 
					@ -111,6 +111,7 @@ exports.disconnect = async () => {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  for (const uuid of Object.keys(jobs)) {
 | 
					  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)");
 | 
					    jobs[uuid].event.emit("error", "Job ended prematurely (not really an error; just run your image job again)");
 | 
				
			||||||
 | 
					    delete jobs[uuid];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  this.connections = [];
 | 
					  this.connections = [];
 | 
				
			||||||
  return;
 | 
					  return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue