diff --git a/src/bit-systems/delete-entity-system.ts b/src/bit-systems/delete-entity-system.ts index 6aa0b76436..1ff5e5dd91 100644 --- a/src/bit-systems/delete-entity-system.ts +++ b/src/bit-systems/delete-entity-system.ts @@ -16,7 +16,7 @@ export type Coroutine = Generator, void, unknown>; const END_SCALE = new Vector3().setScalar(0.001); function* animateThenRemoveEntity(world: HubsWorld, eid: number): Coroutine { if (hasSavedEntityState(world, eid)) { - deleteEntityState(APP.hubChannel!, world, eid); + deleteEntityState(APP.hubChannel!, world, eid).catch(console.warn); } addComponent(world, Deleting, eid); const obj = world.eid2obj.get(eid)!; diff --git a/src/bit-systems/entity-persistence-system.ts b/src/bit-systems/entity-persistence-system.ts index b74a219d4b..9f0272ed07 100644 --- a/src/bit-systems/entity-persistence-system.ts +++ b/src/bit-systems/entity-persistence-system.ts @@ -19,7 +19,7 @@ function* saveEntityStateJob(hubChannel: HubChannel, world: HubsWorld, eid: Enti // Don't save entity state if this entity is no longer persistent if (!hasSavedEntityState(world, eid)) return; - updateEntityState(hubChannel, world, eid); + updateEntityState(hubChannel, world, eid).catch(console.warn); } // TODO type for coroutine diff --git a/src/bit-systems/network-receive-system.ts b/src/bit-systems/network-receive-system.ts index 01c70d10d1..c744e4e1a6 100644 --- a/src/bit-systems/network-receive-system.ts +++ b/src/bit-systems/network-receive-system.ts @@ -79,7 +79,7 @@ export function networkReceiveSystem(world: HubsWorld) { if (eid) { if (hasSavedEntityState(world, eid)) { console.warn("Received delete message for a persistent entity. Deleting its entity state..."); - deleteEntityState(APP.hubChannel!, world, eid); + deleteEntityState(APP.hubChannel!, world, eid).catch(console.warn); } createMessageDatas.delete(eid); world.nid2eid.delete(nid); diff --git a/src/bit-systems/object-menu.ts b/src/bit-systems/object-menu.ts index 44840632df..c03799caec 100644 --- a/src/bit-systems/object-menu.ts +++ b/src/bit-systems/object-menu.ts @@ -148,9 +148,9 @@ function cloneObject(world: HubsWorld, sourceEid: EntityID) { function handleClicks(world: HubsWorld, menu: EntityID, hubChannel: HubChannel) { if (clicked(world, ObjectMenu.pinButtonRef[menu])) { - createEntityState(hubChannel, world, ObjectMenu.targetRef[menu]); + createEntityState(hubChannel, world, ObjectMenu.targetRef[menu]).catch(console.warn); } else if (clicked(world, ObjectMenu.unpinButtonRef[menu])) { - deleteEntityState(hubChannel, world, ObjectMenu.targetRef[menu]); + deleteEntityState(hubChannel, world, ObjectMenu.targetRef[menu]).catch(console.warn); } else if (clicked(world, ObjectMenu.cameraFocusButtonRef[menu])) { console.log("Clicked focus"); } else if (clicked(world, ObjectMenu.cameraTrackButtonRef[menu])) { diff --git a/src/utils/entity-state-utils.ts b/src/utils/entity-state-utils.ts index 105233629d..2a4afc685f 100644 --- a/src/utils/entity-state-utils.ts +++ b/src/utils/entity-state-utils.ts @@ -69,8 +69,12 @@ export async function deleteEntityState(hubChannel: HubChannel, world: HubsWorld } export async function loadSavedEntityStates(hubChannel: HubChannel) { - const list = await listEntityStates(hubChannel); - list.data.forEach(entityState => queueEntityStateAsMessage(entityState)); + try { + const list = await listEntityStates(hubChannel); + list.data.forEach(entityState => queueEntityStateAsMessage(entityState)); + } catch (e) { + console.warn(e); + } } function entityStateCreateMessage(eid: EntityID): CreateMessage { @@ -115,8 +119,7 @@ function push(hubChannel: HubChannel, command: HubChannelCommand, payload?: HubC hubChannel.channel.push(command, payload).receive("ok", resolve).receive("error", reject); }); } else { - console.warn("Entity state API is inactive. Would have sent:", { command, payload }); - return Promise.reject(); + return Promise.reject(`Entity state API is inactive. Would have sent: ${command}, ${JSON.stringify(payload)}`); } } @@ -176,9 +179,11 @@ function downloadAsJson(exportObj: any, exportName: string) { } async function downloadSavedEntityStates(hubChannel: HubChannel) { - listEntityStates(hubChannel).then(list => { - downloadAsJson(list, `hub-${hubChannel.hubId}`); - }); + listEntityStates(hubChannel) + .then(list => { + downloadAsJson(list, `hub-${hubChannel.hubId}`); + }) + .catch(console.warn); } // For debugging @@ -197,7 +202,7 @@ function rebroadcastEntityState(hubChannel: HubChannel, entityState: EntityState update_message: update }; }) - }); + }).catch(console.warn); } function rewriteNidsForEntityState(entityState: EntityState) {