@0dotxyz/p0-ts-sdk 2.2.0-alpha.5 → 2.2.0-alpha.7

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/vendor.cjs CHANGED
@@ -29261,12 +29261,28 @@ var V1Client = class _V1Client {
29261
29261
  return new Promise((resolve, reject) => {
29262
29262
  const ws = new WebSocket__default.default(url, [SUBPROTOCOL]);
29263
29263
  ws.binaryType = "arraybuffer";
29264
- ws.on("open", () => {
29264
+ const onOpen = () => {
29265
+ ws.off("error", onError);
29266
+ ws.off("close", onClose);
29265
29267
  resolve(new _V1Client(ws));
29266
- });
29267
- ws.on("error", (err) => {
29268
+ };
29269
+ const onError = (err) => {
29270
+ ws.off("open", onOpen);
29271
+ ws.off("close", onClose);
29268
29272
  reject(err);
29269
- });
29273
+ };
29274
+ const onClose = (code, reason) => {
29275
+ ws.off("open", onOpen);
29276
+ ws.off("error", onError);
29277
+ reject(
29278
+ new Error(
29279
+ `WebSocket closed before open (code=${code}${reason.length ? `, reason=${reason.toString()}` : ""})`
29280
+ )
29281
+ );
29282
+ };
29283
+ ws.once("open", onOpen);
29284
+ ws.once("error", onError);
29285
+ ws.once("close", onClose);
29270
29286
  });
29271
29287
  }
29272
29288
  // --- Constructor ---