@zlink-systems/stream-connector 0.19.0 → 0.21.0

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.
@@ -69,13 +69,10 @@ export declare class ZlinkStreamConnectorLifecycle {
69
69
  /**
70
70
  * Runs once the teardown promise has settled, so a handler reached from here
71
71
  * may call `connect` without waiting for a task its own caller still holds.
72
- * The reconnect is queued before the notification is awaited for the same
73
- * reason: spec stream-connector 32 §6 has reconnect on by default, and a
72
+ * The reconnect is queued after both notifications have been started for the
73
+ * same reason: spec stream-connector 32 §6 has reconnect on by default, and a
74
74
  * handler that is slow — or whose promise never settles at all — must not
75
- * cost the connector the attempt. The state is already `Disconnected` and the
76
- * state handlers are already invoked by the time the queued microtask runs,
77
- * because `setState` records the state and hands the change to the handlers
78
- * before it awaits any of them.
75
+ * cost the connector the attempt.
79
76
  */
80
77
  private announceDisconnect;
81
78
  private shouldReconnect;
@@ -2167,8 +2167,8 @@ var ZlinkStreamConnectorBundle = (() => {
2167
2167
  }
2168
2168
  const error = toStreamError(cause, "connectTimeout" /* ConnectTimeout */, "Connect failed.");
2169
2169
  (_a = this.closeReasonValue) != null ? _a : this.closeReasonValue = "TransportError";
2170
- await this.setState("disconnected" /* Disconnected */, error, signal);
2171
- await this.publishDisconnectedOnce(signal);
2170
+ void this.setState("disconnected" /* Disconnected */, error, signal);
2171
+ this.publishDisconnectedWithoutWaiting(signal);
2172
2172
  throw new ZlinkStreamException(error);
2173
2173
  }
2174
2174
  }
@@ -2216,7 +2216,7 @@ var ZlinkStreamConnectorBundle = (() => {
2216
2216
  }
2217
2217
  this.pendingRequests.failAll({ code: "disconnected" /* Disconnected */, message: "Connector closed." });
2218
2218
  this.receivedMessages.connectionEnded();
2219
- await this.setState("closed" /* Closed */, void 0, signal);
2219
+ void this.setState("closed" /* Closed */, void 0, signal);
2220
2220
  this.publishDisconnectedWithoutWaiting(signal);
2221
2221
  if (errors.length === 1) throw errors[0];
2222
2222
  if (errors.length > 1) throw new AggregateError(errors, "Stream connector close failed.");
@@ -2450,29 +2450,23 @@ var ZlinkStreamConnectorBundle = (() => {
2450
2450
  /**
2451
2451
  * Runs once the teardown promise has settled, so a handler reached from here
2452
2452
  * may call `connect` without waiting for a task its own caller still holds.
2453
- * The reconnect is queued before the notification is awaited for the same
2454
- * reason: spec stream-connector 32 §6 has reconnect on by default, and a
2453
+ * The reconnect is queued after both notifications have been started for the
2454
+ * same reason: spec stream-connector 32 §6 has reconnect on by default, and a
2455
2455
  * handler that is slow — or whose promise never settles at all — must not
2456
- * cost the connector the attempt. The state is already `Disconnected` and the
2457
- * state handlers are already invoked by the time the queued microtask runs,
2458
- * because `setState` records the state and hands the change to the handlers
2459
- * before it awaits any of them.
2456
+ * cost the connector the attempt.
2460
2457
  */
2461
2458
  async announceDisconnect(error) {
2462
2459
  if (this.closeRequested) return;
2463
2460
  const announce = this.claimDisconnectedPublish();
2464
- const notified = (async () => {
2465
- await this.setState("disconnected" /* Disconnected */, error);
2466
- if (announce) {
2467
- await this.events.publishDisconnected();
2468
- }
2469
- })();
2461
+ void this.setState("disconnected" /* Disconnected */, error);
2462
+ if (announce) {
2463
+ void this.events.publishDisconnected().catch(() => void 0);
2464
+ }
2470
2465
  if (this.shouldReconnect()) {
2471
2466
  queueMicrotask(() => {
2472
2467
  void this.connect().catch(() => void 0);
2473
2468
  });
2474
2469
  }
2475
- await notified;
2476
2470
  }
2477
2471
  shouldReconnect() {
2478
2472
  return this.options.reconnect.enabled && !this.closeRequested;
@@ -2099,8 +2099,8 @@ var ZlinkStreamConnectorLifecycle = class {
2099
2099
  }
2100
2100
  const error = toStreamError(cause, "connectTimeout" /* ConnectTimeout */, "Connect failed.");
2101
2101
  this.closeReasonValue ??= "TransportError";
2102
- await this.setState("disconnected" /* Disconnected */, error, signal);
2103
- await this.publishDisconnectedOnce(signal);
2102
+ void this.setState("disconnected" /* Disconnected */, error, signal);
2103
+ this.publishDisconnectedWithoutWaiting(signal);
2104
2104
  throw new ZlinkStreamException(error);
2105
2105
  }
2106
2106
  }
@@ -2147,7 +2147,7 @@ var ZlinkStreamConnectorLifecycle = class {
2147
2147
  }
2148
2148
  this.pendingRequests.failAll({ code: "disconnected" /* Disconnected */, message: "Connector closed." });
2149
2149
  this.receivedMessages.connectionEnded();
2150
- await this.setState("closed" /* Closed */, void 0, signal);
2150
+ void this.setState("closed" /* Closed */, void 0, signal);
2151
2151
  this.publishDisconnectedWithoutWaiting(signal);
2152
2152
  if (errors.length === 1) throw errors[0];
2153
2153
  if (errors.length > 1) throw new AggregateError(errors, "Stream connector close failed.");
@@ -2377,29 +2377,23 @@ var ZlinkStreamConnectorLifecycle = class {
2377
2377
  /**
2378
2378
  * Runs once the teardown promise has settled, so a handler reached from here
2379
2379
  * may call `connect` without waiting for a task its own caller still holds.
2380
- * The reconnect is queued before the notification is awaited for the same
2381
- * reason: spec stream-connector 32 §6 has reconnect on by default, and a
2380
+ * The reconnect is queued after both notifications have been started for the
2381
+ * same reason: spec stream-connector 32 §6 has reconnect on by default, and a
2382
2382
  * handler that is slow — or whose promise never settles at all — must not
2383
- * cost the connector the attempt. The state is already `Disconnected` and the
2384
- * state handlers are already invoked by the time the queued microtask runs,
2385
- * because `setState` records the state and hands the change to the handlers
2386
- * before it awaits any of them.
2383
+ * cost the connector the attempt.
2387
2384
  */
2388
2385
  async announceDisconnect(error) {
2389
2386
  if (this.closeRequested) return;
2390
2387
  const announce = this.claimDisconnectedPublish();
2391
- const notified = (async () => {
2392
- await this.setState("disconnected" /* Disconnected */, error);
2393
- if (announce) {
2394
- await this.events.publishDisconnected();
2395
- }
2396
- })();
2388
+ void this.setState("disconnected" /* Disconnected */, error);
2389
+ if (announce) {
2390
+ void this.events.publishDisconnected().catch(() => void 0);
2391
+ }
2397
2392
  if (this.shouldReconnect()) {
2398
2393
  queueMicrotask(() => {
2399
2394
  void this.connect().catch(() => void 0);
2400
2395
  });
2401
2396
  }
2402
- await notified;
2403
2397
  }
2404
2398
  shouldReconnect() {
2405
2399
  return this.options.reconnect.enabled && !this.closeRequested;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zlink-systems/stream-connector",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,6 +22,6 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@zlink-systems/stream-wire": "0.19.0"
25
+ "@zlink-systems/stream-wire": "0.21.0"
26
26
  }
27
27
  }