@pythnetwork/pyth-lazer-sdk 6.2.2 → 6.2.4

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/README.md CHANGED
@@ -60,3 +60,77 @@ c.subscribe({
60
60
  jsonBinaryEncoding: "hex",
61
61
  });
62
62
  ```
63
+
64
+ ## Error callbacks and outage detection
65
+
66
+ The SDK exposes two error callbacks and an "all connections down" listener that
67
+ serve distinct purposes. Choose what to handle based on whether you want
68
+ visibility into per-socket churn or a signal that the price stream has actually
69
+ stopped.
70
+
71
+ ### `onWebSocketError` (per-socket errors)
72
+
73
+ Passed via `webSocketPoolConfig.onWebSocketError`. Fires for individual
74
+ socket-level errors on a single underlying WebSocket — for example, a transient
75
+ `502` from one endpoint during a server upgrade or chaos test:
76
+
77
+ ```json
78
+ {
79
+ "at": "pyth#connect",
80
+ "level": "ERROR",
81
+ "error": "Unexpected server response: 502"
82
+ }
83
+ ```
84
+
85
+ **In most cases you never need to handle `onWebSocketError` — it is purely
86
+ informational.** The pool manages each socket's lifecycle (reconnect, retry,
87
+ failover across the configured URLs), so these errors are expected churn when
88
+ one endpoint hiccups. When the SDK is configured with redundant connections
89
+ (`numConnections > 1`, multiple `urls`), a single socket failing does **not**
90
+ mean the stream is dark — the other connections continue delivering messages.
91
+ Treat it as diagnostic only; don't page or alert on it.
92
+
93
+ ### `onWebSocketPoolError` (pool-level errors)
94
+
95
+ Passed via `webSocketPoolConfig.onWebSocketPoolError`. Fires for errors that
96
+ originate from the pool itself rather than a single socket — server-sent
97
+ `subscriptionError`/`error` messages, exceptions thrown by your message
98
+ listeners, send failures, and other internal errors that would otherwise
99
+ surface as unhandled rejections. Applications should listen to this and surface
100
+ it (log, alert, etc.).
101
+
102
+ ```javascript
103
+ webSocketPoolConfig: {
104
+ onWebSocketError: (error) => {
105
+ // Individual socket error — usually safe to log at info/debug.
106
+ console.warn("websocket error (single connection):", error.message);
107
+ },
108
+ onWebSocketPoolError: (error) => {
109
+ // Pool-level error — surface this.
110
+ console.error("websocket pool error:", error);
111
+ },
112
+ },
113
+ ```
114
+
115
+ ### `addAllConnectionsDownListener` (stream is dark)
116
+
117
+ Registered on the client. Fires when **every** redundant connection is down or
118
+ reconnecting at the same time — i.e., the price stream really has stopped.
119
+ This is the right signal for outage detection and paging:
120
+
121
+ ```javascript
122
+ c.addAllConnectionsDownListener(() => {
123
+ console.error("All Lazer connections are down — stream is dark.");
124
+ });
125
+ ```
126
+
127
+ A matching `addConnectionRestoredListener` fires when at least one connection
128
+ comes back after an all-down period.
129
+
130
+ ### Recommendation
131
+
132
+ For detecting real outages, handle `onWebSocketPoolError` and
133
+ `addAllConnectionsDownListener`. Do not page or panic solely on
134
+ `onWebSocketError` when the SDK is configured with redundant endpoints and
135
+ prices are still flowing — individual sockets are expected to flap during
136
+ server upgrades and chaos tests.
@@ -30,7 +30,7 @@ _export(exports, {
30
30
  });
31
31
  const SOLANA_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
32
32
  const SOLANA_LAZER_STORAGE_ID = "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL";
33
- const DEFAULT_METADATA_SERVICE_URL = "https://history.pyth-lazer.dourolabs.app/history";
33
+ const DEFAULT_METADATA_SERVICE_URL = "https://pyth.dourolabs.app";
34
34
  const DEFAULT_PRICE_SERVICE_URL = "https://pyth-lazer-0.dourolabs.app";
35
35
  const DEFAULT_STREAM_SERVICE_0_URL = "wss://pyth-lazer-0.dourolabs.app/v1/stream";
36
36
  const DEFAULT_STREAM_SERVICE_1_URL = "wss://pyth-lazer-1.dourolabs.app/v1/stream";
@@ -1,6 +1,6 @@
1
1
  export declare const SOLANA_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
2
2
  export declare const SOLANA_LAZER_STORAGE_ID = "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL";
3
- export declare const DEFAULT_METADATA_SERVICE_URL = "https://history.pyth-lazer.dourolabs.app/history";
3
+ export declare const DEFAULT_METADATA_SERVICE_URL = "https://pyth.dourolabs.app";
4
4
  export declare const DEFAULT_PRICE_SERVICE_URL = "https://pyth-lazer-0.dourolabs.app";
5
5
  export declare const DEFAULT_STREAM_SERVICE_0_URL = "wss://pyth-lazer-0.dourolabs.app/v1/stream";
6
6
  export declare const DEFAULT_STREAM_SERVICE_1_URL = "wss://pyth-lazer-1.dourolabs.app/v1/stream";
@@ -1,6 +1,6 @@
1
1
  export declare const SOLANA_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
2
2
  export declare const SOLANA_LAZER_STORAGE_ID = "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL";
3
- export declare const DEFAULT_METADATA_SERVICE_URL = "https://history.pyth-lazer.dourolabs.app/history";
3
+ export declare const DEFAULT_METADATA_SERVICE_URL = "https://pyth.dourolabs.app";
4
4
  export declare const DEFAULT_PRICE_SERVICE_URL = "https://pyth-lazer-0.dourolabs.app";
5
5
  export declare const DEFAULT_STREAM_SERVICE_0_URL = "wss://pyth-lazer-0.dourolabs.app/v1/stream";
6
6
  export declare const DEFAULT_STREAM_SERVICE_1_URL = "wss://pyth-lazer-1.dourolabs.app/v1/stream";
@@ -1,6 +1,6 @@
1
1
  export const SOLANA_LAZER_PROGRAM_ID = "pytd2yyk641x7ak7mkaasSJVXh6YYZnC7wTmtgAyxPt";
2
2
  export const SOLANA_LAZER_STORAGE_ID = "3rdJbqfnagQ4yx9HXJViD4zc4xpiSqmFsKpPuSCQVyQL";
3
- export const DEFAULT_METADATA_SERVICE_URL = "https://history.pyth-lazer.dourolabs.app/history";
3
+ export const DEFAULT_METADATA_SERVICE_URL = "https://pyth.dourolabs.app";
4
4
  export const DEFAULT_PRICE_SERVICE_URL = "https://pyth-lazer-0.dourolabs.app";
5
5
  export const DEFAULT_STREAM_SERVICE_0_URL = "wss://pyth-lazer-0.dourolabs.app/v1/stream";
6
6
  export const DEFAULT_STREAM_SERVICE_1_URL = "wss://pyth-lazer-1.dourolabs.app/v1/stream";
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "bugs": {
3
- "url": "https://github.com/pyth-network/pyth-crosschain/issues"
3
+ "url": "https://github.com/pyth-network/pyth-lazer-public/issues"
4
4
  },
5
5
  "dependencies": {
6
- "@isaacs/ttlcache": "^2.1.4",
6
+ "@isaacs/ttlcache": "^2.1.5",
7
7
  "buffer": "^6.0.3",
8
8
  "isomorphic-ws": "^5.0.0",
9
- "ts-log": "^2.2.7",
10
- "ws": "^8.20.0"
9
+ "ts-log": "^3.0.2",
10
+ "ws": "^8.21.0"
11
11
  },
12
12
  "description": "Pyth Lazer SDK",
13
13
  "devDependencies": {
14
- "@cprussin/tsconfig": "^4.0.2",
15
- "@types/node": "^24.10.1",
14
+ "@cprussin/tsconfig": "^5.0.0",
15
+ "@types/node": "^26.0.0",
16
16
  "@types/ws": "^8.18.1",
17
- "typedoc": "^0.28.18"
17
+ "typedoc": "^0.28.19"
18
18
  },
19
19
  "engines": {
20
20
  "node": "^24.0.0"
@@ -135,7 +135,7 @@
135
135
  "files": [
136
136
  "dist/**/*"
137
137
  ],
138
- "homepage": "https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/sdk/js",
138
+ "homepage": "https://github.com/pyth-network/pyth-lazer-public/tree/main/sdk/js",
139
139
  "keywords": [
140
140
  "pyth",
141
141
  "oracle"
@@ -148,9 +148,9 @@
148
148
  "access": "public"
149
149
  },
150
150
  "repository": {
151
- "directory": "lazer/sdk/js",
151
+ "directory": "sdk/js",
152
152
  "type": "git",
153
- "url": "https://github.com/pyth-network/pyth-crosschain"
153
+ "url": "https://github.com/pyth-network/pyth-lazer-public"
154
154
  },
155
155
  "scripts": {
156
156
  "build": "ts-duality --clean",
@@ -164,5 +164,5 @@
164
164
  },
165
165
  "type": "module",
166
166
  "types": "./dist/cjs/index.d.ts",
167
- "version": "6.2.2"
167
+ "version": "6.2.4"
168
168
  }