Skip to content

[Fix] Prevent last run output to leak to next run's logs #3454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2024
Merged
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
8 changes: 3 additions & 5 deletions src/backend/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ const logsWriters: Record<string, LogWriter> = {}

class LogWriter {
gameInfo: GameInfo
queue: string[] | undefined
queue: string[]
initialized: boolean
timeoutId: NodeJS.Timeout | undefined
filePath: string
Expand All @@ -370,11 +370,10 @@ class LogWriter {
this.gameInfo = gameInfo
this.initialized = false
this.filePath = lastPlayLogFileLocation(gameInfo.app_name)
this.queue = []
}

logMessage(message: string) {
this.queue ??= []

// push messages to append to the log
this.queue.push(message)

Expand Down Expand Up @@ -466,8 +465,7 @@ class LogWriter {
}

export function appendGameLog(gameInfo: GameInfo, message: string) {
logsWriters[gameInfo.app_name] ??= new LogWriter(gameInfo)
logsWriters[gameInfo.app_name].logMessage(message)
logsWriters[gameInfo.app_name]?.logMessage(message)
}

export function initGameLog(gameInfo: GameInfo) {
Expand Down