mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
🐛 Fix issue that push messages received before the REST API did
This commit is contained in:
parent
8482e1b363
commit
0510824c24
|
@ -86,13 +86,37 @@ export const pushConnection = mixins(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sometimes the push message is faster as the result from
|
||||||
|
* the REST API so we do not know yet what execution ID
|
||||||
|
* is currently active. So internally resend the message
|
||||||
|
* a few more times
|
||||||
|
*
|
||||||
|
* @param {Event} event
|
||||||
|
* @param {number} retryAttempts
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
retryPushMessage (event: Event, retryAttempts: number) {
|
||||||
|
retryAttempts = retryAttempts -1;
|
||||||
|
|
||||||
|
if (retryAttempts <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.pushMessageReceived(event, retryAttempts);
|
||||||
|
}, 200);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process a newly received message
|
* Process a newly received message
|
||||||
*
|
*
|
||||||
* @param {Event} event The event data with the message data
|
* @param {Event} event The event data with the message data
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
pushMessageReceived (event: Event): void {
|
pushMessageReceived (event: Event, retryAttempts?: number): void {
|
||||||
|
retryAttempts = retryAttempts || 5;
|
||||||
|
|
||||||
let receivedData: IPushData;
|
let receivedData: IPushData;
|
||||||
try {
|
try {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -107,14 +131,13 @@ export const pushConnection = mixins(
|
||||||
// No workflow is running so ignore the messages
|
// No workflow is running so ignore the messages
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Deactivated for now because sometimes the push messages arrive
|
const pushData = receivedData.data as IPushDataNodeExecuteBefore;
|
||||||
// before the execution id gets received
|
if (this.$store.getters.activeExecutionId !== pushData.executionId) {
|
||||||
// const pushData = receivedData.data as IPushDataNodeExecuteBefore;
|
// The data is not for the currently active execution or
|
||||||
// if (this.$store.getters.activeExecutionId !== pushData.executionId) {
|
// we do not have the execution id yet.
|
||||||
// // The data is not for the currently active execution so ignore it.
|
this.retryPushMessage(event, retryAttempts);
|
||||||
// // Should normally not happen but who knows...
|
return;
|
||||||
// return;
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivedData.type === 'executionFinished') {
|
if (receivedData.type === 'executionFinished') {
|
||||||
|
@ -129,8 +152,9 @@ export const pushConnection = mixins(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$store.getters.activeExecutionId !== pushData.executionIdActive) {
|
if (this.$store.getters.activeExecutionId !== pushData.executionIdActive) {
|
||||||
// The workflow which did finish execution did not get started
|
// The workflow which did finish execution did either not get started
|
||||||
// by this session so ignore
|
// by this session or we do not have the execution id yet.
|
||||||
|
this.retryPushMessage(event, retryAttempts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue