-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Cancel runner task on timeout in external mode (#12101)
- Loading branch information
Showing
12 changed files
with
283 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/@n8n/task-runner/src/js-task-runner/errors/task-cancelled-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { ApplicationError } from 'n8n-workflow'; | ||
|
||
export class TaskCancelledError extends ApplicationError { | ||
constructor(reason: string) { | ||
super(`Task cancelled: ${reason}`, { level: 'warning' }); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
packages/@n8n/task-runner/src/js-task-runner/errors/timeout-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ApplicationError } from 'n8n-workflow'; | ||
|
||
export class TimeoutError extends ApplicationError { | ||
description: string; | ||
|
||
constructor(taskTimeout: number) { | ||
super( | ||
`Task execution timed out after ${taskTimeout} ${taskTimeout === 1 ? 'second' : 'seconds'}`, | ||
); | ||
|
||
const subtitle = 'The task runner was taking too long on this task, so the task was aborted.'; | ||
|
||
const fixes = { | ||
optimizeScript: | ||
'Optimize your script to prevent long-running tasks, e.g. by processing data in smaller batches.', | ||
ensureTermination: | ||
'Ensure that all paths in your script are able to terminate, i.e. no infinite loops.', | ||
}; | ||
|
||
const suggestions = [fixes.optimizeScript, fixes.ensureTermination]; | ||
|
||
const suggestionsText = suggestions | ||
.map((suggestion, index) => `${index + 1}. ${suggestion}`) | ||
.join('<br/>'); | ||
|
||
const description = `${subtitle} You can try the following:<br/><br/>${suggestionsText}`; | ||
|
||
this.description = description; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.