Skip to content

Commit

Permalink
fix: Display readable error when manual executions contains large pay…
Browse files Browse the repository at this point in the history
…load (#8834)
  • Loading branch information
krynble authored Mar 8, 2024
1 parent 76fe960 commit 261b9c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,7 @@
"workflowPreview.showError.previewError.title": "Preview error",
"workflowRun.noActiveConnectionToTheServer": "Lost connection to the server",
"workflowRun.showError.title": "Problem running workflow",
"workflowRun.showError.payloadTooLarge": "Please execute the whole workflow, rather than just the node. (Existing execution data is too large.)",
"workflowRun.showMessage.message": "Please fix them before executing",
"workflowRun.showMessage.title": "Workflow has issues",
"workflowSettings.callerIds": "IDs of workflows that can call this one",
Expand Down
24 changes: 18 additions & 6 deletions packages/editor-ui/src/stores/workflows.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useUsersStore } from '@/stores/users.store';
import { useSettingsStore } from '@/stores/settings.store';
import { getCredentialOnlyNodeTypeName } from '@/utils/credentialOnlyNodes';
import { ResponseError } from '@/utils/apiUtils';
import { i18n } from '@/plugins/i18n';

const defaults: Omit<IWorkflowDb, 'id'> & { settings: NonNullable<IWorkflowDb['settings']> } = {
name: '',
Expand Down Expand Up @@ -1338,12 +1340,22 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {

async runWorkflow(startRunData: IStartRunData): Promise<IExecutionPushResponse> {
const rootStore = useRootStore();
return await makeRestApiRequest(
rootStore.getRestApiContext,
'POST',
'/workflows/run',
startRunData as unknown as IDataObject,
);
try {
return await makeRestApiRequest(
rootStore.getRestApiContext,
'POST',
'/workflows/run',
startRunData as unknown as IDataObject,
);
} catch (error) {
if (error.response?.status === 413) {
throw new ResponseError(i18n.baseText('workflowRun.showError.payloadTooLarge'), {
errorCode: 413,
httpStatusCode: 413,
});
}
throw error;
}
},

async removeTestWebhook(workflowId: string): Promise<boolean> {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/utils/apiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { parse } from 'flatted';

export const NO_NETWORK_ERROR_CODE = 999;

class ResponseError extends Error {
export class ResponseError extends Error {
// The HTTP status code of response
httpStatusCode?: number;

Expand Down

0 comments on commit 261b9c7

Please sign in to comment.