





















@@ -645,7 +645,7 @@ export function createGatewayReadyLogScanner(logPath, marker = "[gateway] ready"
645645646646const fd = fs.openSync(logPath, "r");
647647try {
648-const buffer = Buffer.allocUnsafe(Math.min(LOG_SCAN_CHUNK_BYTES, stat.size - offset));
648+const buffer = Buffer.alloc(Math.min(LOG_SCAN_CHUNK_BYTES, stat.size - offset));
649649while (offset < stat.size) {
650650const bytesToRead = Math.min(buffer.length, stat.size - offset);
651651const bytesRead = fs.readSync(fd, buffer, 0, bytesToRead, offset);
@@ -1204,7 +1204,7 @@ export function findErrorLogFindings(logPath) {
1204120412051205const fd = fs.openSync(logPath, "r");
12061206try {
1207-const buffer = Buffer.allocUnsafe(LOG_SCAN_CHUNK_BYTES);
1207+const buffer = Buffer.alloc(LOG_SCAN_CHUNK_BYTES);
12081208let offset = 0;
12091209while (offset < scanBytes) {
12101210const bytesToRead = Math.min(buffer.length, scanBytes - offset);
@@ -1250,9 +1250,9 @@ export function tailFile(file, maxBytes = LOG_TAIL_BYTES) {
12501250const length = stat.size - start;
12511251const fd = fs.openSync(file, "r");
12521252try {
1253-const buffer = Buffer.allocUnsafe(length);
1254-fs.readSync(fd, buffer, 0, length, start);
1255-return tailText(buffer.toString("utf8"));
1253+const buffer = Buffer.alloc(length);
1254+const bytesRead = fs.readSync(fd, buffer, 0, length, start);
1255+return tailText(buffer.subarray(0, bytesRead).toString("utf8"));
12561256} finally {
12571257fs.closeSync(fd);
12581258}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。