reachlo 1.4.0 → 1.4.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.
Files changed (2) hide show
  1. package/index.js +17 -3
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  class Reachlo {
3
3
  constructor(apiKey, options = {}) {
4
4
  this.apiKey = apiKey;
5
- this.url = options.url || 'wss://friendly-octo-barnacle.fly.dev';
5
+ this.url = options.url || 'wss://edge.reachlo.space/';
6
6
  this.socket = null;
7
7
  this.channels = new Map();
8
8
  this.pendingSubs = new Set();
@@ -125,8 +125,8 @@ class Reachlo {
125
125
  resolve();
126
126
  };
127
127
 
128
- this.socket.onclose = () => {
129
- this._log("Reachlo: Connection closed");
128
+ this.socket.onclose = (event) => {
129
+ this._log("Reachlo: Connection closed", event.code, event.reason);
130
130
  this._stopHeartbeat();
131
131
 
132
132
  // SDK Review Fix: ACK Memory Leak Protection
@@ -138,6 +138,20 @@ class Reachlo {
138
138
 
139
139
  this._emitLifecycle('disconnect');
140
140
 
141
+ // PERMANENT FAILURES: Don't reconnect on auth errors
142
+ const permanentFailureCodes = [4001, 4002, 4003, 1008];
143
+ const isAuthFailure = event.code === 4001 ||
144
+ event.reason?.includes('Invalid') ||
145
+ event.reason?.includes('Unauthorized') ||
146
+ event.reason?.includes('quota');
147
+
148
+ if (isAuthFailure || permanentFailureCodes.includes(event.code)) {
149
+ this._error("Reachlo: Permanent failure, not reconnecting.", event.code, event.reason);
150
+ this.shouldReconnect = false;
151
+ this._emitLifecycle('error');
152
+ return;
153
+ }
154
+
141
155
  if (this.shouldReconnect) {
142
156
  if (!this.reconnecting) {
143
157
  this.reconnecting = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reachlo",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "Streaming-native real-time infrastructure. Ordered channels, durable replay, presence, backpressure, and ACK delivery.",
5
5
  "main": "index.js",
6
6
  "type": "module",