Make runtime diagnostics non-blocking and release 2.1.69
CI / verify (push) Canceled after 0s

This commit is contained in:
Sucukdeluxe committed 2026-10-18 02:51:48 +02:00
1 parent 9d96f67261
commit 1e289ee49b
9 files changed
+129 -78

No files matched your search

+30 -1
View File
@@ -180,8 +180,37 @@ function createNativeStartupLog({ fs, path, directory, commandLine, now = Date.n
return target;
} catch { return null; }
};
const listAsync = async pattern => {
const found = [];
try {
for (const entry of await fs.promises.readdir(logDirectory, { withFileTypes: true })) {
if (!entry.isFile() || !pattern.test(entry.name)) continue;
try {
const target = path.join(logDirectory, entry.name);
found.push({ name: entry.name, path: target, modified: (await fs.promises.stat(target)).mtimeMs });
} catch {}
}
} catch {}
return found.sort((a, b) => b.modified - a.modified || b.name.localeCompare(a.name));
};
const filesAsync = async () => (await listAsync(nativePattern)).sort((a, b) => Number(b.path === nativePath) - Number(a.path === nativePath))
.map(file => ({ label: file.name, path: file.path, maxBytes }));
const reportsAsync = async () => (await listAsync(reportPattern)).sort((a, b) => Number(b.path === latestReport) - Number(a.path === latestReport))
.map(file => ({ label: file.name, path: file.path, maxBytes: 5 * 1024 * 1024 }));
const saveReportAsync = async text => {
if (typeof text !== 'string' || Buffer.byteLength(text, 'utf8') > 5 * 1024 * 1024) return null;
try {
await fs.promises.mkdir(logDirectory, { recursive: true });
const target = path.join(logDirectory, `report-${now()}-${pid}-${reportSequence++}.txt`);
await fs.promises.writeFile(target, text, { flag: 'wx', mode: 0o600 });
latestReport = target;
const entries = await listAsync(reportPattern);
for (const file of entries.filter(file => file.path !== target).slice(9)) await fs.promises.unlink(file.path).catch(() => {});
return target;
} catch { return null; }
};
prune(reportPattern, 10);
return { enabled, nativePath, logDirectory, files, reports, saveReport, maintain, maintainAsync };
return { enabled, nativePath, logDirectory, files, filesAsync, reports, reportsAsync, saveReport, saveReportAsync, maintain, maintainAsync };
}
module.exports = { createStartupWindow, resolveStartupLanguage, createStartupQuery, createStartupDiagnostics, summarizeStartupPixels, createNativeStartupLog };