Skip to content

Commit

Permalink
server: catch/print startup errors to console and not just events tab
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Mar 27, 2023
1 parent 84a4ef4 commit 2c23021
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 10 additions & 12 deletions server/python/plugin_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,14 @@ def print(self, nativeId: str, *values: object, sep: Optional[str] = ' ',
nativeId, *values, sep=sep, end=end, flush=flush), self.loop)

async def loadZip(self, packageJson, zipData, options: dict=None):
try:
return await self.loadZipWrapped(packageJson, zipData, options)
except:
print('plugin start/fork failed')
traceback.print_exc()
raise

async def loadZipWrapped(self, packageJson, zipData, options: dict=None):
sdk = ScryptedStatic()

clusterId = options['clusterId']
Expand Down Expand Up @@ -531,20 +539,10 @@ async def forkReadLoop():
self.deviceManager, self.mediaManager)

if not forkMain:
try:
from main import create_scrypted_plugin # type: ignore
except:
print('plugin failed to start')
traceback.print_exc()
raise
from main import create_scrypted_plugin # type: ignore
return await rpc.maybe_await(create_scrypted_plugin())

try:
from main import fork # type: ignore
except:
print('fork failed to start')
traceback.print_exc()
raise
from main import fork # type: ignore
forked = await rpc.maybe_await(fork())
if type(forked) == dict:
forked[rpc.RpcPeer.PROPERTY_JSON_COPY_SERIALIZE_CHILDREN] = True
Expand Down
8 changes: 7 additions & 1 deletion server/src/plugin/plugin-remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,13 @@ export function attachPluginRemote(peer: RpcPeer, options?: PluginRemoteAttachOp

params.pluginRuntimeAPI = ret;

return options.onLoadZip(ret, params, packageJson, zipData, zipOptions);
try {
return await options.onLoadZip(ret, params, packageJson, zipData, zipOptions);
}
catch (e) {
console.error('plugin start/fork failed', e)
throw e;
}
},
}

Expand Down

0 comments on commit 2c23021

Please sign in to comment.