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,15 +1330,21 @@ export class Room { ...@@ -1330,15 +1330,21 @@ export class Room {
? path.resolve(process.cwd(), ocgcoreWasmPathConfig) ? path.resolve(process.cwd(), ocgcoreWasmPathConfig)
: undefined; : undefined;
this.ocgcore = await initWorker(OcgcoreWorker, { try {
seed: duelRecord.seed, this.ocgcore = await initWorker(OcgcoreWorker, {
hostinfo: this.hostinfo, seed: duelRecord.seed,
ygoproPaths: this.resourceLoader.ygoproPaths, hostinfo: this.hostinfo,
extraScriptPaths, ygoproPaths: this.resourceLoader.ygoproPaths,
ocgcoreWasmPath, extraScriptPaths,
registry, ocgcoreWasmPath,
decks: duelRecord.toSwappedPlayers().map((p) => p.deck), registry,
}); 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;
await this.ocgcore.setResponse(msg.response); try {
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