Skip to content

Commit

Permalink
Fix extension function fallbacks
Browse files Browse the repository at this point in the history
As reported in #556, when the extension is not installed or fails to
load, calls to certain extension functions will fail. The issue mentions
the `runningInContainer` broken being broken on the main branch.

PR #554 also removes some safety checks that cause the same issue for
the `diagnoseRaw` function. Those safety checks were removed because
they did not what expected, tracking if the extension was running or
not.

For both functions I've implemented a no-operations function. This will
fix any errors on calls to these functions. Other functions that call
these functions need to handle receiving no return value.

Part of #556, but doesn't fix it entirely. We should call more function
calls. These ones were the most obvious ones.

Based on PR #554.
  • Loading branch information
tombruijn committed Jan 19, 2022
1 parent 24ac4f9 commit 459e9aa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/nodejs/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Extension {
} catch (error) {
return {
error: error,
output: diagnostics_report_string.split("\n")
output: (diagnostics_report_string || "").split("\n")
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion packages/nodejs/src/extension_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ try {
throw new Error("Extension module not loaded")
},
stop() {
return
},
diagnoseRaw() {
},
runningInContainer() {
}
}
} as ExtensionWrapper
Expand Down

0 comments on commit 459e9aa

Please sign in to comment.