Reduce socket batch size to prevent ui lockup when using non-wasm event validation

This commit is contained in:
Jon Staab
2025-10-28 08:33:17 -07:00
parent 7d8f5e05b4
commit 8b8e3a6a51
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -281,7 +281,7 @@ describe("policy", () => {
expect(closeSpy).toHaveBeenCalled() expect(closeSpy).toHaveBeenCalled()
cleanup() cleanup()
}, 50000) }, 100000)
it("should reset timer on send activity", () => { it("should reset timer on send activity", () => {
const cleanup = socketPolicyCloseInactive(socket) const cleanup = socketPolicyCloseInactive(socket)
+4 -2
View File
@@ -31,6 +31,8 @@ export type SocketEvents = {
} }
export class Socket extends EventEmitter { export class Socket extends EventEmitter {
static batchSize = 10
auth: AuthState auth: AuthState
status = SocketStatus.Closed status = SocketStatus.Closed
@@ -44,7 +46,7 @@ export class Socket extends EventEmitter {
this.auth = new AuthState(this) this.auth = new AuthState(this)
this._sendQueue = new TaskQueue<ClientMessage>({ this._sendQueue = new TaskQueue<ClientMessage>({
batchSize: 50, batchSize: Socket.batchSize,
processItem: (message: ClientMessage) => { processItem: (message: ClientMessage) => {
this._ws?.send(JSON.stringify(message)) this._ws?.send(JSON.stringify(message))
this.emit(SocketEvent.Send, message, this.url) this.emit(SocketEvent.Send, message, this.url)
@@ -52,7 +54,7 @@ export class Socket extends EventEmitter {
}) })
this._recvQueue = new TaskQueue<RelayMessage>({ this._recvQueue = new TaskQueue<RelayMessage>({
batchSize: 50, batchSize: Socket.batchSize,
processItem: (message: RelayMessage) => { processItem: (message: RelayMessage) => {
this.emit(SocketEvent.Receive, message, this.url) this.emit(SocketEvent.Receive, message, this.url)
}, },