@debugg-ai/debugg-ai-mcp 1.0.47 → 1.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -199,6 +199,18 @@ process.on('SIGTERM', async () => {
|
|
|
199
199
|
await Telemetry.shutdown();
|
|
200
200
|
process.exit(0);
|
|
201
201
|
});
|
|
202
|
+
process.on('unhandledRejection', (reason) => {
|
|
203
|
+
logger.error('Unhandled promise rejection', {
|
|
204
|
+
error: reason instanceof Error ? reason.message : String(reason),
|
|
205
|
+
stack: reason instanceof Error ? reason.stack : undefined,
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
process.on('uncaughtException', (error) => {
|
|
209
|
+
logger.error('Uncaught exception', {
|
|
210
|
+
error: error.message,
|
|
211
|
+
stack: error.stack,
|
|
212
|
+
});
|
|
213
|
+
});
|
|
202
214
|
/**
|
|
203
215
|
* Start the server
|
|
204
216
|
*/
|
|
@@ -14,6 +14,7 @@ let initialized = false;
|
|
|
14
14
|
* Resolve the current project context: repo → project → environments → credentials.
|
|
15
15
|
* Safe to call multiple times — caches after first successful resolution.
|
|
16
16
|
*/
|
|
17
|
+
const STARTUP_TIMEOUT_MS = 10_000; // hard cap so we never block MCP connection
|
|
17
18
|
export async function resolveProjectContext() {
|
|
18
19
|
if (initialized)
|
|
19
20
|
return cached;
|
|
@@ -23,6 +24,24 @@ export async function resolveProjectContext() {
|
|
|
23
24
|
logger.info('No git repo detected — skipping project context');
|
|
24
25
|
return null;
|
|
25
26
|
}
|
|
27
|
+
try {
|
|
28
|
+
// Race against a timeout so a slow/unreachable backend never blocks startup
|
|
29
|
+
return await Promise.race([
|
|
30
|
+
resolveProjectContextInner(repoName),
|
|
31
|
+
new Promise((resolve) => {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
logger.warn('Project context resolution timed out — continuing without it');
|
|
34
|
+
resolve(null);
|
|
35
|
+
}, STARTUP_TIMEOUT_MS);
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
logger.warn(`Failed to resolve project context: ${err}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
async function resolveProjectContextInner(repoName) {
|
|
26
45
|
try {
|
|
27
46
|
const client = new DebuggAIServerClient(config.api.key);
|
|
28
47
|
await client.init();
|
|
@@ -71,13 +71,20 @@ export const createWorkflowsService = (tx) => {
|
|
|
71
71
|
});
|
|
72
72
|
return execution;
|
|
73
73
|
}
|
|
74
|
+
// Check abort before sleeping to avoid missing a signal fired between polls
|
|
75
|
+
if (signal?.aborted) {
|
|
76
|
+
throw new Error(`Polling cancelled for execution ${executionUuid}`);
|
|
77
|
+
}
|
|
74
78
|
await new Promise((resolve, reject) => {
|
|
75
79
|
const timer = setTimeout(resolve, POLL_INTERVAL_MS);
|
|
76
80
|
if (signal) {
|
|
77
|
-
|
|
81
|
+
const onAbort = () => { clearTimeout(timer); reject(new Error(`Polling cancelled for execution ${executionUuid}`)); };
|
|
82
|
+
if (signal.aborted) {
|
|
78
83
|
clearTimeout(timer);
|
|
79
84
|
reject(new Error(`Polling cancelled for execution ${executionUuid}`));
|
|
80
|
-
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
81
88
|
}
|
|
82
89
|
});
|
|
83
90
|
}
|