From 178951d4fca6356179c3ea622674d625f71b0486 Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Mon, 11 Apr 2022 14:29:37 -0700 Subject: [PATCH 1/7] feat: add ability to cancel containerless function --- .../forceFunctionContainerlessStartCommand.ts | 2 +- .../ForceFunctionContainerlessStartExecutor.ts | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionContainerlessStartCommand.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionContainerlessStartCommand.ts index ac7c59667a..9afadfebf2 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionContainerlessStartCommand.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionContainerlessStartCommand.ts @@ -21,7 +21,7 @@ export const CONTAINER_START_TEXT_KEY = export const FUNCTION_CONTAINER_LOG_NAME = 'force_function_containerless_start'; /** - * Executes sfdx run:function:start:local --verbose + * Starts a local run of the function which can then be invoked with payloads. * @param sourceUri */ export const forceFunctionContainerlessStartCommand = async ( diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts index f1b2508f58..de6ae2cfec 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts @@ -5,13 +5,12 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import { LocalRun } from '@heroku/functions-core'; +import {LocalRun, LocalRunProcess} from '@heroku/functions-core'; import { Disposable } from 'vscode'; import { channelService } from '../../../channels'; import { nls } from '../../../messages'; import { notificationService } from '../../../notifications'; import { telemetryService } from '../../../telemetry'; -import { FUNCTION_TYPE_JAVA } from '../../templates/metadataTypeConstants'; import { FunctionService, functionType } from '../functionService'; import { FUNCTION_DEFAULT_DEBUG_PORT, @@ -20,6 +19,8 @@ import { import { ForceFunctionStartExecutor } from './ForceFunctionStartExecutor'; export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartExecutor { + private process: LocalRunProcess | undefined; + public async setupFunctionListeners(): Promise { console.log('No listeners for containerless function.'); } @@ -27,7 +28,10 @@ export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartE public async cancelFunction( registeredStartedFunctionDisposable: Disposable ): Promise { - // TODO: how to stop the localRun + if (this.process && !this.process.cancelled) { + this.process.cancel(); + this.process = undefined; + } registeredStartedFunctionDisposable.dispose(); } @@ -52,10 +56,8 @@ export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartE localRun .exec() - .then(msg => { - console.log( - `localRun resolved in ForceFunctionContainerlessStartExecutor with message: ${msg}` - ); + .then(process => { + this.process = process; }) .catch((err: Error) => { const errorNotificationMessage = nls.localize( From dcccc0b482aaf1556fa3ae7a4e9c07ccf3085185 Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Wed, 13 Apr 2022 13:32:40 -0700 Subject: [PATCH 2/7] build: update heroku functions core to v0.3.0 --- packages/salesforcedx-vscode-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/salesforcedx-vscode-core/package.json b/packages/salesforcedx-vscode-core/package.json index 75b58f1ce9..fa17c73545 100644 --- a/packages/salesforcedx-vscode-core/package.json +++ b/packages/salesforcedx-vscode-core/package.json @@ -25,7 +25,7 @@ "Other" ], "dependencies": { - "@heroku/functions-core": "^0.2.7", + "@heroku/functions-core": "^0.3.0", "@salesforce/core": "^2.35.0", "@salesforce/salesforcedx-sobjects-faux-generator": "54.7.0", "@salesforce/salesforcedx-utils-vscode": "54.7.0", From 246bedc5374996771a56164b1bc83302c2cfe936 Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Wed, 13 Apr 2022 17:16:57 -0700 Subject: [PATCH 3/7] build: pin @types/chai to 4.3.0 as 4.3.1 has introduced breaking changes --- packages/salesforcedx-apex-debugger/package.json | 2 +- packages/salesforcedx-apex-replay-debugger/package.json | 2 +- packages/salesforcedx-sobjects-faux-generator/package.json | 2 +- packages/salesforcedx-test-utils-vscode/package.json | 2 +- packages/salesforcedx-utils-vscode/package.json | 2 +- .../package.json | 2 +- packages/salesforcedx-vscode-apex-debugger/package.json | 2 +- packages/salesforcedx-vscode-apex-replay-debugger/package.json | 2 +- packages/salesforcedx-vscode-apex/package.json | 2 +- packages/salesforcedx-vscode-core/package.json | 2 +- .../ForceFunctionContainerlessStartExecutor.ts | 1 + packages/salesforcedx-vscode-lightning/package.json | 2 +- packages/salesforcedx-vscode-lwc/package.json | 2 +- packages/salesforcedx-vscode-soql/package.json | 2 +- packages/salesforcedx-vscode-visualforce/package.json | 2 +- .../sfdx-simple/functions/demoJavaScriptFunction/package.json | 2 +- packages/system-tests/package.json | 2 +- 17 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/salesforcedx-apex-debugger/package.json b/packages/salesforcedx-apex-debugger/package.json index 373e4f3d08..080aa4a5ef 100644 --- a/packages/salesforcedx-apex-debugger/package.json +++ b/packages/salesforcedx-apex-debugger/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", "@types/async-lock": "0.0.20", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mocha": "^5", "@types/node": "12.0.12", "@types/rimraf": "^2.0.2", diff --git a/packages/salesforcedx-apex-replay-debugger/package.json b/packages/salesforcedx-apex-replay-debugger/package.json index 2ab1c4fb81..5c1f0c640d 100644 --- a/packages/salesforcedx-apex-replay-debugger/package.json +++ b/packages/salesforcedx-apex-replay-debugger/package.json @@ -19,7 +19,7 @@ "vscode-uri": "1.0.1" }, "devDependencies": { - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mocha": "^5", "@types/node": "12.0.12", "@types/sinon": "^2.3.7", diff --git a/packages/salesforcedx-sobjects-faux-generator/package.json b/packages/salesforcedx-sobjects-faux-generator/package.json index 15ce3308c1..7cdfe5ce7b 100644 --- a/packages/salesforcedx-sobjects-faux-generator/package.json +++ b/packages/salesforcedx-sobjects-faux-generator/package.json @@ -15,7 +15,7 @@ "shelljs": "0.8.5" }, "devDependencies": { - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mocha": "^5", "@types/node": "12.0.12", "@types/rimraf": "^2.0.2", diff --git a/packages/salesforcedx-test-utils-vscode/package.json b/packages/salesforcedx-test-utils-vscode/package.json index 9fe274a9d1..5d347073ca 100644 --- a/packages/salesforcedx-test-utils-vscode/package.json +++ b/packages/salesforcedx-test-utils-vscode/package.json @@ -13,7 +13,7 @@ "shelljs": "0.8.5" }, "devDependencies": { - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/glob": "^7.2.0", "@types/mocha": "^2.2.38", "@types/node": "12.0.12", diff --git a/packages/salesforcedx-utils-vscode/package.json b/packages/salesforcedx-utils-vscode/package.json index 7d3a06d4a3..d7ecf4ade0 100644 --- a/packages/salesforcedx-utils-vscode/package.json +++ b/packages/salesforcedx-utils-vscode/package.json @@ -19,7 +19,7 @@ }, "devDependencies": { "@salesforce/ts-sinon": "1.3.21", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/cross-spawn": "6.0.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", diff --git a/packages/salesforcedx-visualforce-markup-language-server/package.json b/packages/salesforcedx-visualforce-markup-language-server/package.json index a9db1c629d..2ab864dfee 100644 --- a/packages/salesforcedx-visualforce-markup-language-server/package.json +++ b/packages/salesforcedx-visualforce-markup-language-server/package.json @@ -13,7 +13,7 @@ "main": "./out/src/htmlLanguageService.js", "typings": "./out/src/htmlLanguageService", "devDependencies": { - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mocha": "^2.2.38", "@types/node": "12.0.12", "chai": "^4.0.2", diff --git a/packages/salesforcedx-vscode-apex-debugger/package.json b/packages/salesforcedx-vscode-apex-debugger/package.json index 14a9cd0ab6..e0340d3bb5 100644 --- a/packages/salesforcedx-vscode-apex-debugger/package.json +++ b/packages/salesforcedx-vscode-apex-debugger/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mocha": "^5", "@types/node": "12.0.12", "@types/sinon": "^2.3.7", diff --git a/packages/salesforcedx-vscode-apex-replay-debugger/package.json b/packages/salesforcedx-vscode-apex-replay-debugger/package.json index 78ce6a652a..b7da62e0db 100644 --- a/packages/salesforcedx-vscode-apex-replay-debugger/package.json +++ b/packages/salesforcedx-vscode-apex-replay-debugger/package.json @@ -37,7 +37,7 @@ "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", "@salesforce/ts-sinon": "1.3.21", "@types/async-lock": "0.0.20", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", "@types/node": "12.0.12", diff --git a/packages/salesforcedx-vscode-apex/package.json b/packages/salesforcedx-vscode-apex/package.json index ec5b2f7725..ef4f72c6f1 100644 --- a/packages/salesforcedx-vscode-apex/package.json +++ b/packages/salesforcedx-vscode-apex/package.json @@ -40,7 +40,7 @@ "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", "@salesforce/ts-sinon": "1.3.21", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", "@types/node": "12.0.12", diff --git a/packages/salesforcedx-vscode-core/package.json b/packages/salesforcedx-vscode-core/package.json index fa17c73545..9eedb8cd78 100644 --- a/packages/salesforcedx-vscode-core/package.json +++ b/packages/salesforcedx-vscode-core/package.json @@ -45,7 +45,7 @@ "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", "@salesforce/ts-sinon": "^1.0.0", "@types/adm-zip": "^0.4.31", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/glob": "^7.2.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts index de6ae2cfec..5f683e02f2 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts @@ -31,6 +31,7 @@ export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartE if (this.process && !this.process.cancelled) { this.process.cancel(); this.process = undefined; + channelService.appendLine('Stopped containerless function'); } registeredStartedFunctionDisposable.dispose(); } diff --git a/packages/salesforcedx-vscode-lightning/package.json b/packages/salesforcedx-vscode-lightning/package.json index 83403acf4a..19882b1811 100644 --- a/packages/salesforcedx-vscode-lightning/package.json +++ b/packages/salesforcedx-vscode-lightning/package.json @@ -35,7 +35,7 @@ }, "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", "@types/node": "12.0.12", diff --git a/packages/salesforcedx-vscode-lwc/package.json b/packages/salesforcedx-vscode-lwc/package.json index 2857b46bd7..80ebf32973 100644 --- a/packages/salesforcedx-vscode-lwc/package.json +++ b/packages/salesforcedx-vscode-lwc/package.json @@ -42,7 +42,7 @@ }, "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", "@types/node": "12.0.12", diff --git a/packages/salesforcedx-vscode-soql/package.json b/packages/salesforcedx-vscode-soql/package.json index 472b580874..b99b955b3f 100644 --- a/packages/salesforcedx-vscode-soql/package.json +++ b/packages/salesforcedx-vscode-soql/package.json @@ -48,7 +48,7 @@ "@salesforce/soql-common": "0.2.1", "@salesforce/ts-sinon": "1.3.21", "@salesforce/ts-types": "1.5.13", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/debounce": "^1.2.0", "@types/fs-extra": "^8.1.0", "@types/mkdirp": "0.5.2", diff --git a/packages/salesforcedx-vscode-visualforce/package.json b/packages/salesforcedx-vscode-visualforce/package.json index 15c930cd4d..f5d4e29555 100644 --- a/packages/salesforcedx-vscode-visualforce/package.json +++ b/packages/salesforcedx-vscode-visualforce/package.json @@ -33,7 +33,7 @@ }, "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mocha": "^5", "@types/node": "12.0.12", "@types/sinon": "^2.3.7", diff --git a/packages/system-tests/assets/sfdx-simple/functions/demoJavaScriptFunction/package.json b/packages/system-tests/assets/sfdx-simple/functions/demoJavaScriptFunction/package.json index a6a1c312ee..867be83e15 100644 --- a/packages/system-tests/assets/sfdx-simple/functions/demoJavaScriptFunction/package.json +++ b/packages/system-tests/assets/sfdx-simple/functions/demoJavaScriptFunction/package.json @@ -19,7 +19,7 @@ "@salesforce/salesforce-sdk": "^1.3.0" }, "devDependencies": { - "@types/chai": "^4.1.7", + "@types/chai": "4.3.0", "@types/chai-as-promised": "^7.1.0", "@types/mocha": "^5.2.5", "@types/node": "^10.12.18", diff --git a/packages/system-tests/package.json b/packages/system-tests/package.json index e2060840dd..b59813dee8 100644 --- a/packages/system-tests/package.json +++ b/packages/system-tests/package.json @@ -11,7 +11,7 @@ "devDependencies": { "@salesforce/salesforcedx-test-utils-vscode": "54.7.0", "@salesforce/salesforcedx-utils-vscode": "54.7.0", - "@types/chai": "^4.0.0", + "@types/chai": "4.3.0", "@types/mkdirp": "0.5.2", "@types/mocha": "^5", "@types/node": "12.0.12", From a51e18b9184e385b6bb392020a7a54e2cd54bcfa Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Mon, 18 Apr 2022 14:16:27 -0700 Subject: [PATCH 4/7] test: add test for containerless function stop --- ...ForceFunctionContainerlessStartExecutor.ts | 3 +- ...FunctionContainerlessStartExecutor.test.ts | 35 +++++++++++++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts index 5e793a1e92..c0edfcab5c 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts @@ -5,7 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ -import {LocalRun, LocalRunProcess} from '@heroku/functions-core'; +import { LocalRun, LocalRunProcess } from '@heroku/functions-core'; import { Disposable } from 'vscode'; import { channelService } from '../../../channels'; import { nls } from '../../../messages'; @@ -31,7 +31,6 @@ export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartE if (this.process && !this.process.cancelled) { this.process.cancel(); this.process = undefined; - channelService.appendLine('Stopped containerless function'); } registeredStartedFunctionDisposable.dispose(); } diff --git a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.test.ts b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.test.ts index 4e1316dc7b..00c56c06d7 100644 --- a/packages/salesforcedx-vscode-core/test/vscode-integration/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.test.ts +++ b/packages/salesforcedx-vscode-core/test/vscode-integration/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.test.ts @@ -5,6 +5,7 @@ * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ +import { LocalRunProcess } from '@heroku/functions-core'; import { vscodeStub } from '@salesforce/salesforcedx-utils-vscode/out/test/unit/commands/mocks'; import { expect } from 'chai'; import * as proxyquire from 'proxyquire'; @@ -216,19 +217,14 @@ describe('ForceFunctionContainerlessStartExecutor unit tests', () => { }); it('Should be able to call methods that are no-ops for containerless mode.', async () => { - const disposable = { dispose: stub() }; const executor = new ForceFunctionContainerlessStartExecutor( START_KEY, LOG_NAME ); const listenerResult = await executor.setupFunctionListeners( - 'funDirPath', - disposable + 'funDirPath' ); expect(listenerResult).to.equal(undefined); - const cancelResult = await executor.cancelFunction(disposable); - expect(cancelResult).to.equal(undefined); - assert.calledOnce(disposable.dispose); const buildResult = await executor.buildFunction('nameMe', 'funDirPath'); expect(buildResult).to.equal(undefined); }); @@ -260,7 +256,32 @@ describe('ForceFunctionContainerlessStartExecutor unit tests', () => { assert.calledOnce(fakeLocalRunInst.exec); }); - it('Should call telementry when localRun fails.', async () => { + it('Should be able to cancel running function.', async () => { + const fakeProcess = { cancel: stub().resolves() }; + const fakeLocalRunInst = { + exec: stub().resolves(fakeProcess) + }; + const disposable = { + dispose: stub() + }; + const executor = new ForceFunctionContainerlessStartExecutor( + START_KEY, + LOG_NAME + ); + localRunConstructorStub.returns(fakeLocalRunInst); + + // Sets the local process + await executor.startFunction('foo', 'bar'); + + // have to wait for the unawaited promise in exec().then() to resolve + await Promise.resolve(); + + await executor.cancelFunction(disposable); + assert.calledOnce(fakeProcess.cancel); + assert.calledOnce(disposable.dispose); + }); + + it('Should call telemetry when localRun fails.', async () => { const fakeType = 'typescript'; getFunctionTypeStub.returns(fakeType); const errMessage = 'oh noes. FAIL'; From e29dbf55fc205f50b2f5adc778da427490750b99 Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Mon, 2 May 2022 12:00:57 -0700 Subject: [PATCH 5/7] refactor: use async/await for containerless function start --- .../ForceFunctionContainerlessStartExecutor.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts index c0edfcab5c..c2bdbadf5e 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerlessStartExecutor.ts @@ -19,7 +19,7 @@ import { import { ForceFunctionStartExecutor } from './ForceFunctionStartExecutor'; export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartExecutor { - private process: LocalRunProcess | undefined; + private process: LocalRunProcess | undefined | void; public async setupFunctionListeners(): Promise { console.log('No listeners for containerless function.'); @@ -39,7 +39,7 @@ export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartE console.log('No build for containerless function'); } - public startFunction(functionName: string, functionDirPath: string): void { + public async startFunction(functionName: string, functionDirPath: string): Promise { const functionLanguage = FunctionService.instance.getFunctionType(); channelService.appendLine( `Starting ${functionName} of type ${functionLanguage}` @@ -54,11 +54,7 @@ export class ForceFunctionContainerlessStartExecutor extends ForceFunctionStartE const debugType = functionLanguage === functionType.JAVA ? 'java' : 'node'; FunctionService.instance.updateFunction(functionDirPath, debugType, true); - localRun - .exec() - .then(process => { - this.process = process; - }) + this.process = await localRun.exec() .catch((err: Error) => { const errorNotificationMessage = nls.localize( this.UNEXPECTED_ERROR_KEY From 00d721a06d1f4359e07d3054fd8934dda543a69c Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Tue, 3 May 2022 11:10:41 -0700 Subject: [PATCH 6/7] refactor: make container start function as async --- .../forceFunctionStart/ForceFunctionContainerStartExecutor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts index 4a87a10d13..d8b778f208 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts @@ -135,13 +135,13 @@ export class ForceFunctionContainerStartExecutor extends ForceFunctionStartExecu }); } - public startFunction(functionName: string): void { + public async startFunction(functionName: string): Promise { channelService.appendLine(`Starting ${functionName} in container`); if (!this.functionsBinary) { throw new Error('Unable to start function with no binary.'); } - this.functionsBinary.run(functionName, {}).catch(err => { + await this.functionsBinary.run(functionName, {}).catch(err => { console.log(err); }); } From e167115ac8af5c23e29f569b6f0ad24594555496 Mon Sep 17 00:00:00 2001 From: Mohan Raj Rajamanickam Date: Tue, 3 May 2022 11:10:41 -0700 Subject: [PATCH 7/7] refactor: make container start function as async --- .../forceFunctionStart/ForceFunctionContainerStartExecutor.ts | 4 ++-- .../forceFunctionStart/ForceFunctionStartExecutor.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts index 4a87a10d13..d8b778f208 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionContainerStartExecutor.ts @@ -135,13 +135,13 @@ export class ForceFunctionContainerStartExecutor extends ForceFunctionStartExecu }); } - public startFunction(functionName: string): void { + public async startFunction(functionName: string): Promise { channelService.appendLine(`Starting ${functionName} in container`); if (!this.functionsBinary) { throw new Error('Unable to start function with no binary.'); } - this.functionsBinary.run(functionName, {}).catch(err => { + await this.functionsBinary.run(functionName, {}).catch(err => { console.log(err); }); } diff --git a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts index d24fe9e28d..6435283d6a 100644 --- a/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts +++ b/packages/salesforcedx-vscode-core/src/commands/functions/forceFunctionStart/ForceFunctionStartExecutor.ts @@ -110,7 +110,7 @@ export abstract class ForceFunctionStartExecutor extends LibraryCommandletExecut this.buildFunction(functionName, functionDirPath); channelService.appendLine(`Starting ${functionName}`); - this.startFunction(functionName, functionDirPath); + await this.startFunction(functionName, functionDirPath); return true; }