Commit 211a9003 authored by nanahira's avatar nanahira

add more safety

parent 665ff580
Pipeline #43311 passed with stages
in 3 minutes and 23 seconds
...@@ -1330,6 +1330,7 @@ export class Room { ...@@ -1330,6 +1330,7 @@ export class Room {
? path.resolve(process.cwd(), ocgcoreWasmPathConfig) ? path.resolve(process.cwd(), ocgcoreWasmPathConfig)
: undefined; : undefined;
try {
this.ocgcore = await initWorker(OcgcoreWorker, { this.ocgcore = await initWorker(OcgcoreWorker, {
seed: duelRecord.seed, seed: duelRecord.seed,
hostinfo: this.hostinfo, hostinfo: this.hostinfo,
...@@ -1339,6 +1340,11 @@ export class Room { ...@@ -1339,6 +1340,11 @@ export class Room {
registry, registry,
decks: duelRecord.toSwappedPlayers().map((p) => p.deck), decks: duelRecord.toSwappedPlayers().map((p) => p.deck),
}); });
} catch (e) {
this.logger.error({ error: e }, 'Failed to initialize OCGCoreWorker');
await this.sendChat('Failed to initialize game engine.', ChatColor.RED);
return this.finalize(true);
}
const [ const [
player0DeckCount, player0DeckCount,
...@@ -1746,7 +1752,7 @@ export class Room { ...@@ -1746,7 +1752,7 @@ export class Room {
return; return;
} }
if (encodeError) { if (encodeError) {
this.logger.warn( this.logger.error(
{ encodeError, status }, { encodeError, status },
'Failed to decode game message in worker transport', 'Failed to decode game message in worker transport',
); );
...@@ -1860,7 +1866,12 @@ export class Room { ...@@ -1860,7 +1866,12 @@ export class Room {
} }
this.lastResponseRequestMsg = undefined; this.lastResponseRequestMsg = undefined;
this.isRetrying = false; this.isRetrying = false;
try {
await this.ocgcore.setResponse(msg.response); await this.ocgcore.setResponse(msg.response);
} catch (e) {
this.logger.error({ error: e }, 'Failed to set response in ocgcore');
return this.finalize();
}
return this.advance(); return this.advance();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment