jaelis-node 2.2.0 → 2.2.1

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/lib/sync.js +17 -3
  2. package/package.json +1 -1
package/lib/sync.js CHANGED
@@ -53,8 +53,15 @@ class SyncManager extends EventEmitter {
53
53
  // Get local height
54
54
  this.localHeight = await this.storage.getLatestBlockNumber();
55
55
 
56
- // Connect WebSocket
57
- await this._connect();
56
+ // Connect WebSocket — if the endpoint is down, schedule reconnect
57
+ // instead of crashing the whole process
58
+ try {
59
+ await this._connect();
60
+ } catch (error) {
61
+ console.error('[SYNC] Initial connection failed:', error.message);
62
+ this._scheduleReconnect();
63
+ return;
64
+ }
58
65
 
59
66
  // Get network height and start sync
60
67
  await this._initialSync();
@@ -98,10 +105,17 @@ class SyncManager extends EventEmitter {
98
105
  });
99
106
 
100
107
  this.ws.on('error', (error) => {
108
+ console.error('[SYNC] WebSocket error:', error.message);
101
109
  if (!this.isConnected) {
110
+ // Initial connection failed — reject the promise so start()
111
+ // can catch it and call _scheduleReconnect(). The 'close'
112
+ // event will fire next; we return early so it doesn't also
113
+ // call _scheduleReconnect a second time.
102
114
  reject(error);
115
+ return;
103
116
  }
104
- this.emit('error', error);
117
+ // Don't emit('error') — Node crashes if no listener is attached.
118
+ // The 'close' event will fire after this and trigger _scheduleReconnect.
105
119
  });
106
120
 
107
121
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jaelis-node",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Official JAELIS Blockchain External Node - Connect to the JAELIS network, sync blocks, and expose local RPC for your dApps. Zero gas fees, multi-chain interop.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {