Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions quizbowl/QuestionRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,25 @@ export default class QuestionRoom extends Room {

if (doNotFetch) { return; }

switch (this.mode) {
case MODE_ENUM.SET_NAME:
this.packet = await this.getPacket({ setName: this.query.setName, packetNumber: this.query.packetNumbers[0] });
break;
case MODE_ENUM.RANDOM:
for (const s of this.supportedQuestionTypes) {
const query = { ...this.query, number: 1 };
this.randomQuestionCache[s] = this.categoryManager.percentView
? []
: await this.getRandomQuestions(s, query);
}
break;
try {
switch (this.mode) {
case MODE_ENUM.SET_NAME:
this.packet = await this.getPacket({ setName: this.query.setName, packetNumber: this.query.packetNumbers[0] });
break;
case MODE_ENUM.RANDOM:
for (const s of this.supportedQuestionTypes) {
const query = { ...this.query, number: 1 };
this.randomQuestionCache[s] = this.categoryManager.percentView
? []
: await this.getRandomQuestions(s, query);
}
break;
}
} catch (error) {
// adjustQuery is invoked fire-and-forget from message handlers, so a
// rejected DB call here would become an unhandled rejection and crash
// the process. Log and bail; the next getNextQuestion will refetch.
console.error(`adjustQuery failed to fetch questions in room ${this.name}:`, error);
}
}

Expand Down
Loading