instar 0.24.5 → 0.24.6

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/cli.js CHANGED
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAskCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA2qFtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/commands/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAwPH,UAAU,YAAY;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;2DACuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAskCD,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CA8rFtE;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsDzE;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD5E"}
@@ -2799,14 +2799,16 @@ export async function startServer(options) {
2799
2799
  catch {
2800
2800
  console.warn('[SleepWake] tmux check failed after wake');
2801
2801
  }
2802
- // Restart tunnel if configured — use forceStop to handle zombie cloudflared
2803
- // processes that may be hung after sleep. Race with a 15s overall timeout
2804
- // to prevent the wake handler itself from blocking indefinitely.
2802
+ // Restart tunnel if configured — disable auto-reconnect first to prevent
2803
+ // a cascade of competing reconnection attempts, then forceStop to handle
2804
+ // zombie cloudflared processes that may be hung after sleep.
2805
2805
  if (tunnel) {
2806
2806
  try {
2807
2807
  await Promise.race([
2808
2808
  (async () => {
2809
+ tunnel.disableAutoReconnect();
2809
2810
  await tunnel.forceStop(5000);
2811
+ tunnel.enableAutoReconnect();
2810
2812
  const tunnelUrl = await tunnel.start();
2811
2813
  console.log(`[SleepWake] Tunnel restarted: ${tunnelUrl}`);
2812
2814
  // Re-broadcast dashboard URL after tunnel restart (quick tunnels get new URL)
@@ -2820,6 +2822,8 @@ export async function startServer(options) {
2820
2822
  }
2821
2823
  catch (err) {
2822
2824
  console.error(`[SleepWake] Tunnel restart failed:`, err);
2825
+ // Re-enable auto-reconnect even on failure so it can self-heal
2826
+ tunnel.enableAutoReconnect();
2823
2827
  }
2824
2828
  }
2825
2829
  // Notify via batcher — wake events are informational, not urgent
@@ -3698,6 +3702,20 @@ export async function startServer(options) {
3698
3702
  // the "mutex lock failed" error on next start. This doesn't prevent the crash,
3699
3703
  // but ensures the next boot is clean.
3700
3704
  process.on('uncaughtException', (err) => {
3705
+ // Non-fatal HTTP errors — log and continue, don't crash the server.
3706
+ // "Cannot set headers" is a double-response race condition (common during
3707
+ // tunnel reconnect storms). The affected request is already handled; the
3708
+ // server can keep serving new requests.
3709
+ const nonFatalPatterns = [
3710
+ 'Cannot set headers after they are sent',
3711
+ 'write after end',
3712
+ 'ERR_HTTP_HEADERS_SENT',
3713
+ 'ERR_STREAM_WRITE_AFTER_END',
3714
+ ];
3715
+ if (nonFatalPatterns.some(p => err.message?.includes(p))) {
3716
+ console.warn(`[WARN] Non-fatal uncaught exception (suppressed): ${err.message}`);
3717
+ return; // Don't crash — the server is fine
3718
+ }
3701
3719
  console.error('[FATAL] Uncaught exception — closing databases before crash:', err.message);
3702
3720
  try {
3703
3721
  topicMemory?.close();