Skip to content

Releases: nktkas/rews

v4.0.1

10 Jun 16:58
5908083

Choose a tag to compare

  • A connection that fails before lifecycle listeners attach (e.g. a fetch-blocked port on Node.js) no longer hangs the instance forever. (b7cb983, 5908083)
  • readyState is typed 0 | 1 | 2 | 3, fixing compilation on TypeScript 6 for consumers without skipLibCheck. (fec3ba6)

Full Changelog: v4.0.0...v4.0.1

v4.0.0

10 Jun 15:41
78682bb

Choose a tag to compare

Major redesign of the reconnection and termination semantics.

Reconnection policy

  • maxRetries defaults to Infinity (was 3) and counts consecutive failed attempts: the counter resets only after a connection stays open for stableTimeout (new option, default 3s). A server that accepts and immediately drops connections can no longer bypass the limit. (1e4e2cc, fdc41ac)
  • The default backoff gained equal jitter (delay/2 + random(delay/2), capped at 10s). (fdc41ac)
  • New shouldReconnect(closeEvent, attempt) option — return false to stop reconnecting, terminating with code RECONNECTION_DECLINED. Not consulted for close()/reconnect() calls. (89fc695)
  • Errors thrown by url/protocols factories count as failed attempts and follow the normal retry flow (was: instant permanent termination). (cacd11f)
  • While reconnecting, readyState is CONNECTING (was CLOSED between attempts); CLOSED now always means permanently terminated, and CLOSING is never reported. (ad09cc9)

Termination

  • terminationSignal is the single termination API — the terminate event, isTerminated, and terminationReason are removed. The abort reason is always a ReconnectingWebSocketError with a code. (4ec19e3)
  • The signal aborts before the final close event (in v3 the order varied by termination path). (fba5b8f)

close() and reconnect()

  • close(code?, reason?) is strictly WHATWG and always terminates permanently. (3992b90)
  • The permanently boolean argument is replaced by reconnect(code?, reason?) — drops the current connection and reconnects immediately, not counted towards maxRetries. (3992b90)

Drop-in fidelity

  • url returns the configured URL immediately for static URLs (was "" until the first connection). (d8a5f6b)
  • binaryType set before the first connection applies to the first connection. (5597855)
  • Reassigning onmessage/onclose/etc. keeps the handler's position in the listener order, per spec. (d8a5f6b)
  • bufferedAmount includes messages buffered while disconnected. (25f68bb)
  • The offline buffer is flushed after the open event, so messages sent from an open listener (e.g. authentication) go out first. (2f502ed)
  • Close code 0, reported by some runtimes on connection failure, is normalized to 1006. (d8a5f6b)

React Native

  • Fixed a listener leak and unhandled-rejection spam caused by React Native's AbortController polyfill. (3524df6)
  • The README now also covers the AbortController polyfill needed for terminationSignal.reason. (e8b4d19)

Removed

  • The custom WebSocket constructor option — sockets are always created from globalThis.WebSocket. (b09f1d3)

Full Changelog: v3.0.0...v4.0.0

v3.0.0

06 Jun 02:03
942d78f

Choose a tag to compare

What's Changed

  • build!: require Node.js >=22.12.0 and migrate ESM-only in 3851b6a

Full Changelog: v2.1.2...v3.0.0

v2.1.2

04 Jun 18:28
5e8b9cf

Choose a tag to compare

What's Changed

  • fix: React Native crash on synthetic close during CONNECTING (#7) in 7b62e8f

Full Changelog: v2.1.1...v2.1.2

v2.1.1

10 Apr 01:46
d2c87f0

Choose a tag to compare

What's Changed

  • fix: add internal polyfills for CloseEvent, MessageEvent, and CustomEvent by @Minnzen in #6
  • fix: cross-runtime close event fixes, test refactor, and add CI by @nktkas in 643c63a

New Contributors

Full Changelog: v2.1.0...v2.1.1

v2.1.0

04 Apr 20:44
b13135b

Choose a tag to compare

  • feat: support async URL and protocols (e288452)

Full Changelog: v2.0.2...v2.1.0

v2.0.2

28 Feb 16:31
149060a

Choose a tag to compare

  • fix: return CLOSED readyState after permanent termination (1ca4d01)
  • docs: clarify behavior of close method when maxRetries is set to 0 (c576da0)

Full Changelog: v2.0.1...v2.0.2

v2.0.1

24 Feb 05:36
c66b225

Choose a tag to compare

  • refactor: small changes in internal code (0bb42ec)

Full Changelog: v2.0.0...v2.0.1

v2.0.0

22 Feb 01:15
9298400

Choose a tag to compare

  • refactor!: rewrite core reconnection and test infrastructure (9298400)

Full Changelog: v1.2.3...v2.0.0

v1.2.3

25 Dec 05:00
133d277

Choose a tag to compare

What's Changed

  • fix: add DOMException polyfill by @nktkas in #3

Full Changelog: v1.2.2...v1.2.3