Skip to content
Closed
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
40 changes: 0 additions & 40 deletions src/__tests__/http-batch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,46 +191,6 @@ describe("newHttpBatchRpcSession batching", () => {
});
});

// --- Symbol.dispose tests ---

describe("newHttpBatchRpcSession Symbol.dispose", () => {
it("has Symbol.dispose property", async () => {
const { transport } = mockTransport();
type Svc = { test(): string };
const client = newHttpBatchRpcSession<Svc>({ transport });

expect(typeof client[Symbol.dispose]).toBe("function");
});

it("Symbol.dispose can be called without throwing", async () => {
const { transport } = mockTransport();
type Svc = { test(): string };
const client = newHttpBatchRpcSession<Svc>({ transport });

expect(() => {
client[Symbol.dispose]();
}).not.toThrow();
});

it("Symbol.dispose is non-enumerable", async () => {
const { transport } = mockTransport();
type Svc = { test(): string };
const client = newHttpBatchRpcSession<Svc>({ transport });

expect(Object.keys(client)).toHaveLength(0);
});

it("spreading the proxy does not include Symbol.dispose", async () => {
const { transport } = mockTransport();
type Svc = { test(): string };
const client = newHttpBatchRpcSession<Svc>({ transport });

const spread = { ...client };
expect(Object.keys(spread)).toHaveLength(0);
expect(Symbol.dispose in spread).toBe(false);
});
});

// --- Server HTTP handler tests ---

describe("newHttpBatchRpcResponse", () => {
Expand Down
22 changes: 0 additions & 22 deletions src/__tests__/workers.workers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,26 +319,4 @@ describe("Workers runtime integration tests", () => {
await expect(session.remote.add(1, 2)).rejects.toThrow();
});
});

describe("Symbol.dispose in Workers runtime", () => {
it("should have Symbol.dispose as a function on HTTP batch proxy", async () => {
const session = newHttpBatchRpcSession({
url: "http://localhost:8000",
transport: async (body: string) => {
const response = await SELF.fetch("http://localhost/rpc", {
method: "POST",
headers: { "Content-Type": "application/json" },
body,
});
return response.text();
},
});

// Verify Symbol.dispose is a function on the proxy
expect(typeof session[Symbol.dispose]).toBe("function");

// Clean up
session[Symbol.dispose]();
});
});
});
7 changes: 2 additions & 5 deletions src/http-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type PendingCall = {
*/
export function newHttpBatchRpcSession<T extends object>(
options: RpcClientOptions,
): PromisifyMethods<T> & Disposable {
): PromisifyMethods<T> {
let transport: RpcRequestFn;

if (typeof options === "string") {
Expand Down Expand Up @@ -208,9 +208,6 @@ export function newHttpBatchRpcSession<T extends object>(
{},
{
get(_target, prop) {
if (prop === Symbol.dispose) {
return () => {};
}
if (typeof prop === "symbol") return undefined;
if (RESERVED_PROPS.has(prop as string)) return undefined;
if (prop === "notify") return undefined;
Expand All @@ -226,7 +223,7 @@ export function newHttpBatchRpcSession<T extends object>(
};
},
},
) as PromisifyMethods<T> & Disposable;
) as PromisifyMethods<T>;
}

export { RpcError } from "./core.js";
Loading