MINOR: fix test connection showing timeout even after being successfull (#20260)

* fix test connection showing timeout even after being successfull

* clear the timeout if the execution is being finished and reverted the last commit changes
This commit is contained in:
Ashish Gupta 2025-03-15 11:17:50 +05:30 committed by GitHub
parent 153358a216
commit 4ec19e56a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -165,7 +165,7 @@ const TestConnection: FC<TestConnectionProps> = ({
setTestConnectionStepResult([]); setTestConnectionStepResult([]);
setTestStatus(undefined); setTestStatus(undefined);
setIsConnectionTimeout(false); setIsConnectionTimeout(false);
setProgress(0); setProgress(TEST_CONNECTION_PROGRESS_PERCENTAGE.ZERO);
}; };
const handleDeleteWorkflow = async (workflowId: string) => { const handleDeleteWorkflow = async (workflowId: string) => {
@ -206,6 +206,7 @@ const TestConnection: FC<TestConnectionProps> = ({
response: Workflow, response: Workflow,
intervalObject: { intervalObject: {
intervalId?: number; intervalId?: number;
timeoutId?: number;
} }
) => { ) => {
// return a promise that wraps the interval and handles errors inside it // return a promise that wraps the interval and handles errors inside it
@ -242,6 +243,7 @@ const TestConnection: FC<TestConnectionProps> = ({
// clear the current interval // clear the current interval
clearInterval(intervalObject.intervalId); clearInterval(intervalObject.intervalId);
clearTimeout(intervalObject.timeoutId);
// set testing connection to false // set testing connection to false
setIsTestingConnection(false); setIsTestingConnection(false);
@ -269,6 +271,7 @@ const TestConnection: FC<TestConnectionProps> = ({
// current interval id // current interval id
const intervalObject: { const intervalObject: {
intervalId?: number; intervalId?: number;
timeoutId?: number;
} = {}; } = {};
try { try {
@ -312,7 +315,7 @@ const TestConnection: FC<TestConnectionProps> = ({
} }
// stop fetching the workflow after 2 minutes // stop fetching the workflow after 2 minutes
setTimeout(() => { const timeoutId = setTimeout(() => {
// clear the current interval // clear the current interval
clearInterval(intervalObject.intervalId); clearInterval(intervalObject.intervalId);
@ -333,6 +336,8 @@ const TestConnection: FC<TestConnectionProps> = ({
setProgress(TEST_CONNECTION_PROGRESS_PERCENTAGE.HUNDRED); setProgress(TEST_CONNECTION_PROGRESS_PERCENTAGE.HUNDRED);
}, FETCHING_EXPIRY_TIME); }, FETCHING_EXPIRY_TIME);
intervalObject.timeoutId = Number(timeoutId);
// Handle workflow polling and completion // Handle workflow polling and completion
await handleWorkflowPolling(response, intervalObject); await handleWorkflowPolling(response, intervalObject);
} catch (error) { } catch (error) {