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

+3 -3
View File
@@ -7,7 +7,7 @@ const { McpAccessError } = require('./mcp-access');
function createMcpDiagnostics({ getSources = () => [], redact }) {
let reading = 0;
const guard = context => { if (context.signal?.aborted || !Number.isFinite(context.deadline) || Date.now() >= context.deadline) throw new McpAccessError('REQUEST_EXPIRED'); };
const sources = () => getSources().slice(0, 64).map(source => ({ ...source, id: createHash('sha256').update(source.path).digest('hex').slice(0, 24) }));
const sources = async () => (await getSources()).slice(0, 64).map(source => ({ ...source, id: createHash('sha256').update(source.path).digest('hex').slice(0, 24) }));
const resolve = async source => {
const actual = await fs.realpath(source.path);
const parent = await fs.realpath(source.directory);
@@ -21,7 +21,7 @@ function createMcpDiagnostics({ getSources = () => [], redact }) {
return {
mhu_diagnostics_files: async (args, context) => {
const files = [];
for (const source of sources()) {
for (const source of await sources()) {
guard(context);
try { const { stat } = await resolve(source); files.push({ id: source.id, name: source.label, sizeBytes: stat.size, modifiedAt: stat.mtime.toISOString() }); }
catch (error) { if (!['ENOENT', 'ENOTDIR'].includes(error.code)) files.push({ id: source.id, name: source.label, unavailable: true }); }
@@ -31,7 +31,7 @@ function createMcpDiagnostics({ getSources = () => [], redact }) {
},
mhu_diagnostics_read: async (args, context) => {
guard(context);
const source = sources().find(item => item.id === args.artifactId);
const source = (await sources()).find(item => item.id === args.artifactId);
if (!source) throw new McpAccessError('DIAGNOSTIC_NOT_FOUND');
if (reading >= 4) throw new McpAccessError('TOO_MANY_REQUESTS');
reading++;