@thinkingos/vsl-mcp-server 1.1.0 → 1.1.2

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
@@ -2412,12 +2412,18 @@ var BrowserManager = class {
2412
2412
  */
2413
2413
  async close() {
2414
2414
  this.activeDownloads.clear();
2415
- if (this.context) {
2416
- await this.context.close();
2415
+ try {
2416
+ if (this.context) {
2417
+ await this.context.close();
2418
+ this.context = null;
2419
+ }
2420
+ if (this.browser) {
2421
+ await this.browser.close();
2422
+ this.browser = null;
2423
+ }
2424
+ } catch (error) {
2425
+ console.error("[BrowserManager] Error during close():", error);
2417
2426
  this.context = null;
2418
- }
2419
- if (this.browser) {
2420
- await this.browser.close();
2421
2427
  this.browser = null;
2422
2428
  }
2423
2429
  this.page = null;
@@ -2591,10 +2597,14 @@ var SessionManager = class {
2591
2597
  */
2592
2598
  async closeAll() {
2593
2599
  this.stopCleanup();
2594
- const closePromises = Array.from(this.sessions.values()).map(
2595
- (context) => context.browser.close()
2596
- );
2597
- await Promise.all(closePromises);
2600
+ const closePromises = Array.from(this.sessions.values()).map(async (context) => {
2601
+ try {
2602
+ await context.browser.close();
2603
+ } catch (error) {
2604
+ console.error("[SessionManager] Error closing browser session:", error);
2605
+ }
2606
+ });
2607
+ await Promise.allSettled(closePromises);
2598
2608
  this.sessions.clear();
2599
2609
  }
2600
2610
  /**
@@ -2682,11 +2692,21 @@ async function main() {
2682
2692
  console.error(`[VSL MCP Server] Default session ID: ${defaultSessionId}`);
2683
2693
  const shutdown = async () => {
2684
2694
  console.error("[VSL MCP Server] Shutting down...");
2685
- await sessionManager.closeAll();
2695
+ try {
2696
+ await sessionManager.closeAll();
2697
+ } catch (error) {
2698
+ console.error("[VSL MCP Server] Error during shutdown:", error);
2699
+ }
2686
2700
  process.exit(0);
2687
2701
  };
2688
2702
  process.on("SIGINT", shutdown);
2689
2703
  process.on("SIGTERM", shutdown);
2704
+ process.on("uncaughtException", (error) => {
2705
+ console.error("[VSL MCP Server] Uncaught exception:", error);
2706
+ });
2707
+ process.on("unhandledRejection", (reason, promise) => {
2708
+ console.error("[VSL MCP Server] Unhandled rejection at:", promise, "reason:", reason);
2709
+ });
2690
2710
  }
2691
2711
  main().catch((error) => {
2692
2712
  console.error("[VSL MCP Server] Fatal error:", error);