Skip to content
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

Bug: logger 大量日志由于同步问题不会写入文件 #338

Closed
Hieuzest opened this issue Dec 6, 2024 · 1 comment
Closed

Bug: logger 大量日志由于同步问题不会写入文件 #338

Hieuzest opened this issue Dec 6, 2024 · 1 comment

Comments

@Hieuzest
Copy link
Contributor

Hieuzest commented Dec 6, 2024

flush() {
if (!this.temp.length) return
this.task = this.task.then(async (handle) => {
const content = Buffer.from(this.temp.map((record) => JSON.stringify(record) + '\n').join(''))
await handle.write(content)
this.data.push(...this.temp)
this.size += content.byteLength
this.temp = []
return handle
})
}

此处 await 后 temp 可能发生改变,导致大量日志被丢弃未能写入文件

@shigma
Copy link
Member

shigma commented Dec 11, 2024

Fixed by #339

@shigma shigma closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants