Browse Source

Workaround for 'Error: The child process has exited unexpectedly.' bug

master
Menci 6 years ago
parent
commit
47b04b7b9f
  1. 14
      src/runner/rmq.ts

14
src/runner/rmq.ts

@ -40,13 +40,25 @@ export async function waitForTask(handle: (task: RPCRequest) => Promise<any>) {
} }
response({ type: RPCReplyType.Started }); response({ type: RPCReplyType.Started });
while (true) {
try { try {
const request = msgpack.decode(msg.content) as RPCRequest; const request = msgpack.decode(msg.content) as RPCRequest;
const result = await handle(request); const result = await handle(request);
response({ type: RPCReplyType.Finished, result: result }); response({ type: RPCReplyType.Finished, result: result });
break;
} catch (err) { } catch (err) {
winston.warn(`Failed to run task ${msg.properties.correlationId}: ${err.toString()}, ${err.stack}`); let errorMessage = `Failed to run task ${msg.properties.correlationId}: ${err.toString()}, ${err.stack}`;
winston.warn(errorMessage);
// Only retry on 'Error: The child process has exited unexpectedly.'
if (errorMessage.indexOf('Error: The child process has exited unexpectedly.') !== -1) {
winston.warn('Retrying.');
continue;
}
response({ type: RPCReplyType.Error, error: err.toString() }); response({ type: RPCReplyType.Error, error: err.toString() });
break;
}
} }
channel.ack(msg); channel.ack(msg);

Loading…
Cancel
Save