diff --git a/packages/nodejs/.changesets/fix-extension-fallback-functions.md b/packages/nodejs/.changesets/fix-extension-fallback-functions.md new file mode 100644 index 00000000..b169ec65 --- /dev/null +++ b/packages/nodejs/.changesets/fix-extension-fallback-functions.md @@ -0,0 +1,6 @@ +--- +bump: "patch" +type: "fix" +--- + +Fix the extension function fallbacks on installation failure. When the extension fails to install and calls are made to the unloaded functions, it will no longer throw an error. diff --git a/packages/nodejs/src/__tests__/extension.failure.test.ts b/packages/nodejs/src/__tests__/extension.failure.test.ts index b4738e63..2c7b8fb7 100644 --- a/packages/nodejs/src/__tests__/extension.failure.test.ts +++ b/packages/nodejs/src/__tests__/extension.failure.test.ts @@ -30,4 +30,15 @@ describe("Extension", () => { ext.stop() }).not.toThrow() }) + + it("does not error on diagnoseRaw", () => { + expect(ext.diagnose()).toMatchObject({ + error: expect.any(Error), + output: [""] + }) + }) + + it("does not error on runningInContainer", () => { + expect(ext.runningInContainer()).toBeUndefined() + }) }) diff --git a/packages/nodejs/src/extension.ts b/packages/nodejs/src/extension.ts index bf12b261..7562e3cf 100644 --- a/packages/nodejs/src/extension.ts +++ b/packages/nodejs/src/extension.ts @@ -48,7 +48,7 @@ export class Extension { } catch (error) { return { error: error, - output: diagnostics_report_string.split("\n") + output: (diagnostics_report_string || "").split("\n") } } } diff --git a/packages/nodejs/src/extension_wrapper.ts b/packages/nodejs/src/extension_wrapper.ts index c2510d97..44d16e5d 100644 --- a/packages/nodejs/src/extension_wrapper.ts +++ b/packages/nodejs/src/extension_wrapper.ts @@ -12,9 +12,9 @@ try { start() { throw new Error("Extension module not loaded") }, - stop() { - return - } + stop() {}, + diagnoseRaw() {}, + runningInContainer() {} } } as ExtensionWrapper }