[SQL-bindings] remove watcher for files (#20250)

* remove watcher for files

* nit
This commit is contained in:
Vasu Bhog
2022-08-05 16:18:03 -07:00
committed by GitHub
parent 9dee889808
commit 4ebe4c4547
4 changed files with 3 additions and 82 deletions

View File

@@ -26,7 +26,6 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
TelemetryReporter.sendActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.startCreateAzureFunctionWithSqlBinding);
let connectionInfo: IConnectionInfo | undefined;
let isCreateNewProject: boolean = false;
let newFunctionFileObject: azureFunctionsUtils.IFileFunctionObject | undefined;
try {
// check to see if Azure Functions Extension is installed
@@ -101,9 +100,6 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
// user has an azure function project open
projectFolder = path.dirname(projectFile);
}
// create a system file watcher for the project folder
newFunctionFileObject = azureFunctionsUtils.waitForNewFunctionFile(projectFolder);
// Get connection string parameters and construct object name from prompt or connectionInfo given
let objectName: string | undefined;
let selectedBindingType: BindingType | undefined;
@@ -263,9 +259,6 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
.withAdditionalProperties(propertyBag)
.withConnectionInfo(connectionInfo).send();
// check for the new function file to be created and dispose of the file system watcher
const timeoutForFunctionFile = utils.timeoutPromise(constants.timeoutAzureFunctionFileError);
await Promise.race([newFunctionFileObject.filePromise, timeoutForFunctionFile]);
telemetryStep = 'finishCreateFunction';
propertyBag.telemetryStep = telemetryStep;
exitReason = ExitReason.finishCreate;
@@ -275,15 +268,9 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
} catch (error) {
let errorType = utils.getErrorType(error);
propertyBag.telemetryStep = telemetryStep;
if (errorType === 'TimeoutError') {
// this error can be cause by many different scenarios including timeout or error occurred during createFunction
exitReason = 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 = ExitReason.error;
void vscode.window.showErrorMessage(constants.errorNewAzureFunction(error));
}
// an error occurred during createFunction
exitReason = ExitReason.error;
void vscode.window.showErrorMessage(constants.errorNewAzureFunction(error));
TelemetryReporter.createErrorEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick, undefined, errorType)
.withAdditionalProperties(propertyBag).send();
return;
@@ -292,7 +279,6 @@ export async function createAzureFunction(node?: ITreeNodeInfo): Promise<void> {
propertyBag.exitReason = exitReason;
TelemetryReporter.createActionEvent(TelemetryViews.CreateAzureFunctionWithSqlBinding, TelemetryActions.exitCreateAzureFunctionQuickpick)
.withAdditionalProperties(propertyBag).send();
newFunctionFileObject?.watcherDisposable.dispose();
}
}