mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
🐛 Fix bug that child process did exit before message got sent
This commit is contained in:
parent
62e8a69f78
commit
e1a9d21254
|
@ -133,11 +133,20 @@ export class WorkflowRunnerProcess {
|
||||||
*
|
*
|
||||||
* @param {string} type The type of data to send
|
* @param {string} type The type of data to send
|
||||||
* @param {*} data The data
|
* @param {*} data The data
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
function sendToParentProcess(type: string, data: any): void { // tslint:disable-line:no-any
|
async function sendToParentProcess(type: string, data: any): Promise<void> { // tslint:disable-line:no-any
|
||||||
process.send!({
|
return new Promise((resolve, reject) => {
|
||||||
type,
|
process.send!({
|
||||||
data,
|
type,
|
||||||
|
data,
|
||||||
|
}, (error: Error) => {
|
||||||
|
if (error) {
|
||||||
|
return reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +161,7 @@ process.on('message', async (message: IProcessMessage) => {
|
||||||
if (message.type === 'startWorkflow') {
|
if (message.type === 'startWorkflow') {
|
||||||
const runData = await workflowRunner.runWorkflow(message.data);
|
const runData = await workflowRunner.runWorkflow(message.data);
|
||||||
|
|
||||||
sendToParentProcess('end', {
|
await sendToParentProcess('end', {
|
||||||
runData,
|
runData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -186,7 +195,7 @@ process.on('message', async (message: IProcessMessage) => {
|
||||||
workflowRunner.sendHookToParentProcess('workflowExecuteAfter', [fullRunData]);
|
workflowRunner.sendHookToParentProcess('workflowExecuteAfter', [fullRunData]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendToParentProcess('end', {
|
await sendToParentProcess('end', {
|
||||||
fullRunData,
|
fullRunData,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -200,9 +209,9 @@ process.on('message', async (message: IProcessMessage) => {
|
||||||
stack: error.stack,
|
stack: error.stack,
|
||||||
} as IExecutionError;
|
} as IExecutionError;
|
||||||
|
|
||||||
sendToParentProcess('processError', {
|
await sendToParentProcess('processError', {
|
||||||
executionError,
|
executionError,
|
||||||
});
|
});
|
||||||
process.exit();
|
process.exit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue