Skip to content

Commit 0d8aada

Browse files
authored
feat(core): Make all http requests made with httpRequestWithAuthentication abortable (#11704)
1 parent 3202e8c commit 0d8aada

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/core/src/NodeExecuteFunctions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,10 @@ function convertN8nRequestToAxios(n8nRequest: IHttpRequestOptions): AxiosRequest
918918

919919
axiosRequest.params = n8nRequest.qs;
920920

921+
if (n8nRequest.abortSignal) {
922+
axiosRequest.signal = n8nRequest.abortSignal;
923+
}
924+
921925
if (n8nRequest.baseURL !== undefined) {
922926
axiosRequest.baseURL = n8nRequest.baseURL;
923927
}
@@ -1718,6 +1722,11 @@ export async function httpRequestWithAuthentication(
17181722
) {
17191723
removeEmptyBody(requestOptions);
17201724

1725+
// Cancel this request on execution cancellation
1726+
if ('getExecutionCancelSignal' in this) {
1727+
requestOptions.abortSignal = this.getExecutionCancelSignal();
1728+
}
1729+
17211730
let credentialsDecrypted: ICredentialDataDecryptedObject | undefined;
17221731
try {
17231732
const parentTypes = additionalData.credentialsHelper.getParentTypes(credentialsType);

packages/workflow/src/Interfaces.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22

33
import type { CallbackManager as CallbackManagerLC } from '@langchain/core/callbacks/manager';
4-
import type { AxiosProxyConfig } from 'axios';
4+
import type { AxiosProxyConfig, GenericAbortSignal } from 'axios';
55
import type * as express from 'express';
66
import type FormData from 'form-data';
77
import type { PathLike } from 'fs';
@@ -529,6 +529,7 @@ export interface IHttpRequestOptions {
529529
};
530530
timeout?: number;
531531
json?: boolean;
532+
abortSignal?: GenericAbortSignal;
532533
}
533534

534535
/**

0 commit comments

Comments
 (0)