paranext / paranext-core

Electron client, extension host, and C# library for Paranext
https://paranext.github.io/paranext-core/
MIT License
17 stars 2 forks source link

Extension can break app #1295

Open Sebastian-ubs opened 1 week ago

Sebastian-ubs commented 1 week ago

Describe the bug When an extension works improperly it can break the whole app. ~Maybe here it is caused by a bad d.ts file provided, not sure.~ According to the error message the problem is registering the same command multiple times.

Error: requestType command:webViewer.openWiBiLex already has a remote handler registered

image

[start:core] [1] 10:10:36 [extension host warning] 10:10:36.372 > Extension webViewer specified its type declaration file was at src/types/web-viewer.d.ts, but this path does not seem to exist. Trying other options [at C:\code\paranext-core\src\extension-host\services\extension.service.ts:503:18]

[start:core] [1] 10:10:43 [start:core] [1] [extension host error] [start:core] [1] C:\code\paranext-core\src\shared\services\network.service.ts:210 [start:core] [1] if (!response.success) throw new Error(response.errorMessage); [start:core] [1] ^ [start:core] [1] [/extension host error] [start:core] [1] 10:10:43 [start:core] [1] [extension host error] [start:core] [1] Error: requestType command:webViewer.openWiBiLex already has a remote handler registered [start:core] [1] at requestUnsafe (C:\code\paranext-core\src\shared\services\network.service.ts:210:32) [start:core] [1] at processTicksAndRejections (node:internal/process/task_queues:95:5) [start:core] [1] at async registerRequestHandlerUnsafe (C:\code\paranext-core\src\shared\services\network.service.ts:321:5) [start:core] [1] [/extension host error] [start:core] [1] 10:10:43 Client 1 disconnected! Unregistering extensionAsset:getExtensionAsset, object:platform.menuDataServiceDataProvider-data.get, object:platform.menuDataServiceDataProvider-data.function, object:ProjectSettingsService.get, ...

[start:core] [1] 10:10:57 [dotnet data provider error] Request failed: "Request: object:platform.settingsServiceDataProvider-data.function (2) from 2" with error message "No handler was found to process the request of type object:platform.settingsServiceDataProvider-data.function"

[start:core] [1] 10:10:59 Could not get platform-bible-toolbar menu data! Error: Menu data service undefined [at transport C:\code\paranext-core.erb\dll\main.bundle.dev.js:4207:15]

Logs logs.txt

Expected behavior In case of errors in the extension, the app should continue to run and only trow out the extension's functionality.

Environment Dev, Windows

Sebastian-ubs commented 1 week ago

Fatal: when the extension breaks platform you cannot disable the app through the marketplace, because it won't run

Sebastian-ubs commented 1 week ago

Another way to crash the whole app is requesting a webview that has undefined content. E.g. when they are defined through webview options, which are an optional parameter and undefined otherwise. See (Discord)

papi.webViews.getWebView("myExtension.webView");

The problem is not that such request can be done, but that platform does not catch and handle the error gracefully without crrashing itself.

[start:core] [1] 11:35:18 [start:core] [1] [extension host error] [start:core] [1] C:\code\paranext-core\src\shared\services\network.service.ts:210 [start:core] [1] if (!response.success) throw new Error(response.errorMessage); [start:core] [1] ^ [start:core] [1] [/extension host error] [start:core] [1] 11:35:18 [start:core] [1] [extension host error] [start:core] [1] Error: Input must be a string [start:core] [1] at requestUnsafe (C:\code\paranext-core\src\shared\services\network.service.ts:210:32) [start:core] [1] at processTicksAndRejections (node:internal/process/task_queues:95:5) [start:core] [1] [/extension host error] [start:core] [1] 11:35:18 Client 1 disconnected! Unregistering [...]

[start:core] [1] 11:35:18 [extension host] [nodemon] app crashed - waiting for file changes before starting...

(but I have not seen the app to recover from this state. When removing the bad code, the app won't come up again, so the whole app has to be shut down and started fresh)