Repository navigation
4.18.0
Fixed
use(useWebSocket(url).client.ready)resolves. React retries a render that suspended without its state, so each
retry made a new client and waited for that one instead: in Chrome, 243 sockets in 4 seconds. The retry now gets
the client the first attempt started.client.close()with a code the browser rejects, such as1001, throws before anything changes. It used to throw
halfway, leaving the statusopen,socketnull and the real socket open, with its messages ignored.- A client closed, or one that gave up, while nothing held it starts again for the next hook to mount, as after the
last hook unmounted. It used to stayclosedfor good. migrate()delivers a message the old connection received while an asyncschemawas still validating it.- The client connects in a Web Worker, which has no
window. - Topics send nothing while the server closes the socket, which still reads
openuntil its close event. A release
and hold there used to be queued, and sent after the new connection's subscriptions: the server ended up
unsubscribed from a topic still held. - A request on a
closedclient rejects and leaves it closed. It used to move it toidle, so the next request
opened it again. - The library's own messages that must arrive go on WebTransport's stream, never as datagrams that can be lost:
outbox entries, request cancels, responder replies, feed resumes and AG-UI resyncs. In Chrome, outbox orders went
as datagrams. runs.start()with the id of a run it knows starts nothing. With an ended run's id, it used to reset its value to
'', keep it ended, and hold the connection open for good.- A
cancelrun'scancelis sent withqueue: falsetoo. - A duplicated tab, or one opened with
window.open, no longer cancels thecancelruns of the page it was copied
from: a page waits 200 ms for another to say it still follows a remembered run before cancelling it. The original
page used to show the cancelled run as streaming forever. - AG-UI asks for a snapshot again each time a delta fails after one, not only the first time in a run, and a run
that finished stale no longer makes the next run skip its deltas. applyPatchrejects an array'slengthas a member (replace /list/lengthused to truncate the array) and
pointers that don't start with/, and adds__proto__as a key of its own.- Outbox, without
ack: a message sent right away is no longer stored. Its delete could run before its write, so it
stayed stored and was sent again on the next page load. outbox.remove(),outbox.clear()and acknowledgements reach the other tabs' outboxes with the samename, which
drop the entry too. After aclear()in one tab, another used to send what it had loaded.- Outbox
add()resolves once IndexedDB has committed the write, and its database connection closes when another
page deletes or upgrades the database, which it used to block. - Tabs: a tab that closes lets go of the shared connection and its topics on
pagehide. The leader used to keep
both for it: the last live tab's unsubscribe was swallowed, and the shared socket stayed open. - Tabs: with
json, thetopicsfunctions only get messages that parse, and one that throws counts as no topic. The
guide's example threw on a heartbeat'ping', which never reached the server. - Tabs, where the Web Locks API is missing:
binaryType: 'arraybuffer'is honored, instead of always aBlob. - WebTransport:
close()while connecting reports its own code, not1006.
Documentation
<Activity>: a component usinguseWebSocket(url)keeps its client, and itslastMessage, across hide and show.- Suspense: a connection started only by reading
readykeeps retrying a server that's down until it opens, gives up
orclose()is called, since the client can't tell an abandoned read from a suspended render. - WebTransport: some server libraries, such as aioquic's event API, only see the client's stream once it writes, so
they can't send first.
This is the first release on npm since 4.0.0. It also includes 4.1.0 through 4.17.0, which were versioned in the changelog but not published; see the changelog for what each one changed.