Reputation: 1
I have a queue that starts a game on the backend and a function handleGameStart, where I change the game’s status in the database (from OPEN to STARTED). I can’t see any console.log or logger messages in the console, nor any messages on the client side, but the game status still changes.
@Process(JobNames.SCHEDULE_START_GAME)
async startGame(job: Job<any>) {
this.logger.log(`GAME ${job.data._id} START`);
const prevGameStance = job.data;
try {
const server = this.gameService.getServer();
this.logger.log(`Starting game ${prevGameStance._id}`);
const startedGame = await this.gameService.handleGameStart(
prevGameStance._id,
);
['waitingRoom', 'game'].forEach((room) => {
server.to(`${room}:${prevGameStance._id}`).emit('game:start', {
message: 'Game started',
game: startedGame,
});
});
return { success: true, from: 'backend' };
} catch (error) {
this.logger.error(`Error starting game ${prevGameStance._id}:`, error);
return { success: false, message: 'Failed to start game' };
}
}
The only place where it changes is in this function. And job from queue resolves successfully and this logs works properly.
@OnGlobalQueueCompleted()
onQueueCompleted(jobId: string) {
this.logger.log('--------------------------------');
this.logger.log(`Job ${jobId} completed`);
this.logger.log('--------------------------------');
}
So maybee someone can explain what it is? It's usually works like that when delay small (less than 5 minutes)
Upvotes: 0
Views: 30