Improve error handling in streaming/index.js (#5968)
On an unhandled worker exception, we should log the exception and exit with nonzero status, instead of letting workers silently fail and restarting them in an endless loop. Note: we previously tried to handle the `'error'` signal. That's not a signal Node fires; my patch traps `'uncaughtException'`, which is what the code was _trying_ to do.
This commit is contained in:
		
							parent
							
								
									9a7fb53a7f
								
							
						
					
					
						commit
						d0f4496805
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -563,12 +563,14 @@ const startWorker = (workerId) => {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const onError = (err) => {
 | 
					  const onError = (err) => {
 | 
				
			||||||
    log.error(err);
 | 
					    log.error(err);
 | 
				
			||||||
 | 
					    server.close();
 | 
				
			||||||
 | 
					    process.exit(0);
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  process.on('SIGINT', onExit);
 | 
					  process.on('SIGINT', onExit);
 | 
				
			||||||
  process.on('SIGTERM', onExit);
 | 
					  process.on('SIGTERM', onExit);
 | 
				
			||||||
  process.on('exit', onExit);
 | 
					  process.on('exit', onExit);
 | 
				
			||||||
  process.on('error', onError);
 | 
					  process.on('uncaughtException', onError);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
throng({
 | 
					throng({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue