From 4e299dc4b24ba32b4c8e88dba20dbaaf705eb881 Mon Sep 17 00:00:00 2001 From: Vasu Bhog Date: Thu, 7 Apr 2022 13:58:57 -0700 Subject: [PATCH] fix timeout warning when exiting create function (#18947) * fix timeout warning when exiting create function * combine timeout errors * make more explicit --- .../src/services/azureFunctionsService.ts | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/extensions/sql-bindings/src/services/azureFunctionsService.ts b/extensions/sql-bindings/src/services/azureFunctionsService.ts index f63afd49a3..cc86b36380 100644 --- a/extensions/sql-bindings/src/services/azureFunctionsService.ts +++ b/extensions/sql-bindings/src/services/azureFunctionsService.ts @@ -67,11 +67,23 @@ export async function createAzureFunction(connectionString: string, schema: stri projectFile = await azureFunctionsUtils.getAzureFunctionProject(); } } catch (error) { - void vscode.window.showErrorMessage(utils.formatString(constants.errorNewAzureFunction, error.message ?? error)); let errorType = utils.getErrorType(error); - TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.helpCreateAzureFunctionProject, undefined, errorType).send(); + propertyBag.quickPickStep = quickPickStep; + + if (errorType === 'TimeoutError') { + // this error can be cause by many different scenarios including timeout or error occurred during createFunction + exitReason = 'timeout'; + console.log('Timed out waiting for Azure Function project to be created. This may not necessarily be an error, for example if the user canceled out of the create flow.'); + } else { + // else an error would occur during the createFunction + exitReason = 'error'; + void vscode.window.showErrorMessage(utils.formatString(constants.errorNewAzureFunction, error.message ?? error)); + } + TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick, undefined, errorType) + .withAdditionalProperties(propertyBag).send(); return; } finally { + propertyBag.exitReason = exitReason; TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick) .withConnectionInfo(connectionInfo) .withAdditionalProperties(propertyBag).send(); @@ -147,12 +159,21 @@ export async function createAzureFunction(connectionString: string, schema: stri .withAdditionalProperties(propertyBag) .withConnectionInfo(connectionInfo).send(); } catch (e) { + let errorType = utils.getErrorType(e); propertyBag.quickPickStep = quickPickStep; - exitReason = 'error'; - void vscode.window.showErrorMessage(utils.getErrorMessage(e)); - TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick, undefined, utils.getErrorType(e)) + if (errorType === 'TimeoutError') { + // this error can be cause by many different scenarios including timeout or error occurred during createFunction + exitReason = 'timeout'; + console.log('Timed out waiting for Azure Function project to be created. This may not necessarily be an error, for example if the user canceled out of the create flow.'); + } else { + // else an error would occur during the createFunction + exitReason = 'error'; + void vscode.window.showErrorMessage(utils.getErrorMessage(e)); + } + TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick, undefined, errorType) .withAdditionalProperties(propertyBag).send(); + return; } finally { propertyBag.quickPickStep = quickPickStep; propertyBag.exitReason = exitReason;