From 9650d47e99033ef3b727dcd2c132bd14f932c382 Mon Sep 17 00:00:00 2001 From: Hieuzest Date: Thu, 12 Dec 2024 00:53:44 +0800 Subject: [PATCH] fix(logger): not flushing all records to file (#339) --- plugins/logger/src/file.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/logger/src/file.ts b/plugins/logger/src/file.ts index b71be7e8..287f144a 100644 --- a/plugins/logger/src/file.ts +++ b/plugins/logger/src/file.ts @@ -23,10 +23,10 @@ export class FileWriter { 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 = [] + await handle.write(content) + this.size += content.byteLength return handle }) }