Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@replit/river",
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.207.0",
"version": "0.207.1",
"type": "module",
"exports": {
".": {
Expand Down
8 changes: 7 additions & 1 deletion transport/sessionStateMachine/SessionConnected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@ export class SessionConnected<
// if we are not actively heartbeating, we are in passive
// heartbeat mode and should send a response to the ack
if (!this.isActivelyHeartbeating) {
this.sendHeartbeat();
// purposefully make this async to avoid weird browser behavior
// where _some_ browsers will decide that it is ok to interrupt fully
// synchronous code execution (e.g. an existing .send) to receive a
// websocket message and hit this codepath
void Promise.resolve().then(() => {
this.sendHeartbeat();
});
}
};

Expand Down
4 changes: 4 additions & 0 deletions transport/sessionStateMachine/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ export abstract class IdentifiedSession extends CommonSession {
constructMsg<Payload>(
partialMsg: PartialTransportMessage<Payload>,
): TransportMessage<Payload> {
if (this._isConsumed) {
throw new Error(ERR_CONSUMED);
}

const msg = {
...partialMsg,
id: generateId(),
Expand Down
4 changes: 3 additions & 1 deletion transport/sessionStateMachine/stateMachine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,9 @@ describe('session state machine', () => {
);

// make sure the session acks the heartbeat
expect(conn.send).toHaveBeenCalledTimes(1);
await waitFor(() => {
expect(conn.send).toHaveBeenCalledTimes(1);
});
});

test('does not dispatch acks', async () => {
Expand Down