Skip to content

Commit

Permalink
catch system updates error so the scene keeps working (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonpombo8 authored Feb 20, 2024
1 parent 9ff48a9 commit cf1e4e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/worker-sdk7/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,4 @@ async function sleep(ms: number): Promise<boolean> {
return true
}

createRpcClient(WebWorkerTransportV2(self)).then(startSceneRuntime)
createRpcClient(WebWorkerTransportV2(self)).then(startSceneRuntime).catch(console.error)
6 changes: 5 additions & 1 deletion src/worker-sdk7/sdk7-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ export function createModuleRuntime(
},
async runUpdate(deltaTime: number) {
if (module.exports.onUpdate) {
await module.exports.onUpdate(deltaTime)
try {
await module.exports.onUpdate(deltaTime)
} catch (e: any) {
devtools.error(e)
}
}
await runSetImmediate()
}
Expand Down

0 comments on commit cf1e4e2

Please sign in to comment.