MCPcopy Create free account
hub / github.com/chhoumann/quickadd / stop

Method stop

src/interactive/interactivePromptServer.ts:341–366  ·  view source on GitHub ↗

Stop the server and drop all sessions (plugin unload).

()

Source from the content-addressed store, hash-verified

339
340 /** Stop the server and drop all sessions (plugin unload). */
341 stop(): void {
342 // Invalidate any in-flight ensureStarted() so its listen() callback
343 // discards the server instead of installing it after unload.
344 this.generation++;
345 for (const session of this.sessions.values()) {
346 if (session.waiterTimer) window.clearTimeout(session.waiterTimer);
347 if (session.cleanupTimer) window.clearTimeout(session.cleanupTimer);
348 if (session.attachTimer) window.clearTimeout(session.attachTimer);
349 if (session.pollWatchdog) window.clearTimeout(session.pollWatchdog);
350 for (const [, pending] of session.pending) {
351 pending.reject(new Error("QuickAdd unloaded"));
352 }
353 // Close any parked long-poll response so it isn't orphaned after
354 // server.close() (which won't terminate in-flight connections).
355 if (session.waiter) {
356 const waiter = session.waiter;
357 session.waiter = null;
358 waiter({ kind: "error", error: "QuickAdd unloaded" });
359 }
360 }
361 this.sessions.clear();
362 this.server?.close();
363 this.server = null;
364 this.port = 0;
365 this.startPromise = null;
366 }
367
368 private push(session: Session, event: ServerEvent): void {
369 if (session.waiter) {

Callers 1

onunloadMethod · 0.80

Calls 2

closeMethod · 0.65
clearMethod · 0.45

Tested by

no test coverage detected