mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-06 16:34:36 +00:00
fix(server): bound stale websocket connections
Track application ownership per physical socket and terminate abandoned or backpressured transports without disrupting replacement connections.
This commit is contained in:
@@ -21,6 +21,7 @@ export const CLIENT_CAPS = {
|
||||
// COMPAT(projectUpdates): added in v0.1.109, remove gate after 2027-01-15.
|
||||
projectUpdates: "project_updates",
|
||||
browserHost: "browser_host",
|
||||
applicationSocketLease: "application_socket_lease",
|
||||
} as const;
|
||||
|
||||
export type ClientCapability = (typeof CLIENT_CAPS)[keyof typeof CLIENT_CAPS];
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import { expect, test } from "vitest";
|
||||
import { CLIENT_CAPS } from "./client-capabilities.js";
|
||||
import { WSHelloMessageSchema } from "./messages.js";
|
||||
|
||||
const legacyHello = {
|
||||
type: "hello" as const,
|
||||
clientId: "client-1",
|
||||
clientType: "browser" as const,
|
||||
protocolVersion: 1,
|
||||
};
|
||||
|
||||
test("hello accepts the application socket lease capability", () => {
|
||||
const hello = WSHelloMessageSchema.parse({
|
||||
...legacyHello,
|
||||
capabilities: { [CLIENT_CAPS.applicationSocketLease]: true },
|
||||
});
|
||||
|
||||
expect(hello.capabilities?.[CLIENT_CAPS.applicationSocketLease]).toBe(true);
|
||||
});
|
||||
|
||||
test("hello remains compatible when the application socket lease capability is absent", () => {
|
||||
const hello = WSHelloMessageSchema.parse(legacyHello);
|
||||
|
||||
expect(hello.capabilities).toBeUndefined();
|
||||
});
|
||||
@@ -5565,6 +5565,7 @@ export const WSHelloMessageSchema = z.object({
|
||||
[CLIENT_CAPS.providerSubagents]: z.boolean().optional(),
|
||||
[CLIENT_CAPS.projectUpdates]: z.boolean().optional(),
|
||||
[CLIENT_CAPS.browserHost]: BrowserAutomationHostCapabilitySchema.optional(),
|
||||
[CLIENT_CAPS.applicationSocketLease]: z.boolean().optional(),
|
||||
})
|
||||
.passthrough()
|
||||
.optional(),
|
||||
|
||||
Reference in New Issue
Block a user