nstantpage-agent 0.3.2 → 0.3.3

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/tunnel.d.ts CHANGED
@@ -45,6 +45,8 @@ export declare class TunnelClient {
45
45
  /**
46
46
  * Start reconnecting in the background (non-blocking).
47
47
  * Used when initial connect() fails so the dev server can keep running.
48
+ * The close handler from the failed connect() already schedules a reconnect,
49
+ * so we just ensure shouldReconnect is true and don't duplicate.
48
50
  */
49
51
  startBackgroundReconnect(): void;
50
52
  disconnect(): void;
package/dist/tunnel.js CHANGED
@@ -106,11 +106,17 @@ export class TunnelClient {
106
106
  /**
107
107
  * Start reconnecting in the background (non-blocking).
108
108
  * Used when initial connect() fails so the dev server can keep running.
109
+ * The close handler from the failed connect() already schedules a reconnect,
110
+ * so we just ensure shouldReconnect is true and don't duplicate.
109
111
  */
110
112
  startBackgroundReconnect() {
111
113
  this.shouldReconnect = true;
112
- this.reconnectAttempts = 0;
113
- this.scheduleReconnect();
114
+ // Only kick off a reconnect if there isn't one already pending
115
+ // (the close handler from the failed connect() already scheduled one)
116
+ if (!this.reconnectTimer) {
117
+ this.reconnectAttempts = 0;
118
+ this.scheduleReconnect();
119
+ }
114
120
  }
115
121
  disconnect() {
116
122
  this.shouldReconnect = false;
@@ -235,6 +241,8 @@ export class TunnelClient {
235
241
  scheduleReconnect() {
236
242
  if (!this.shouldReconnect)
237
243
  return;
244
+ if (this.reconnectTimer)
245
+ return; // Already have a pending reconnect
238
246
  if (this.reconnectAttempts >= this.maxReconnectAttempts) {
239
247
  console.error(' [Tunnel] Max reconnect attempts reached. Giving up.');
240
248
  return;
@@ -243,6 +251,7 @@ export class TunnelClient {
243
251
  this.reconnectAttempts++;
244
252
  console.log(` [Tunnel] Reconnecting in ${delay / 1000}s (attempt ${this.reconnectAttempts})...`);
245
253
  this.reconnectTimer = setTimeout(async () => {
254
+ this.reconnectTimer = null; // Clear so next scheduleReconnect can fire
246
255
  try {
247
256
  await this.connect();
248
257
  console.log(' [Tunnel] Reconnected!');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nstantpage-agent",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Local development agent for nstantpage.com — run your projects locally, preview in the cloud. Replaces cloud containers for faster builds.",
5
5
  "type": "module",
6
6
  "bin": {