Skip to content
Draft
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
9 changes: 9 additions & 0 deletions __tests__/test-server-workerd.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export class TestDo extends DurableObject {
getValue() {
return this.value;
}

subscribe(callback) {
this.subscriber = callback.dup();
}

async notify(value) {
await this.subscriber(value);
this.subscriber[Symbol.dispose]();
}
}

export class TestTarget extends RpcTarget {
Expand Down
15 changes: 15 additions & 0 deletions __tests__/workerd.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ interface Env {
interface TestDo extends DurableObject {
setValue(val: any): void;
getValue(): any;

subscribe(callback: (s: string) => void): void;
notify(value: string): void;
}

interface WorkerdTestTarget extends TestTarget {
Expand Down Expand Up @@ -268,6 +271,18 @@ describe("workerd RPC server", () => {
expect(await foo.getValue()).toBe(123);
expect(await bar.getValue()).toBe("abc");
}

{
let baz = cap.getDurableObject("baz");

let receivedValue: any;

await baz.subscribe((value: any) => {receivedValue = value});

await baz.notify("hello");

expect(receivedValue).toBe("hello");
}
})

it("can accept HTTP batch RPC connections", async () => {
Expand Down
67 changes: 25 additions & 42 deletions package-lock.json

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

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"tsx": "^4.21.0",
"typescript": "^5.9.3",
"vitest": "^3.2.4",
"workerd": "1.20251223.0",
"ws": "^8.18.3"
},
"repository": {
Expand All @@ -55,5 +56,8 @@
"bugs": {
"url": "https://github.com/cloudflare/capnweb/issues"
},
"homepage": "https://github.com/cloudflare/capnweb#readme"
"homepage": "https://github.com/cloudflare/capnweb#readme",
"overrides": {
"workerd": "1.20251223.0"
}
}
3 changes: 2 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default defineConfig({
workers: {
miniflare: {
compatibilityDate: '2025-07-01',
compatibilityFlags: ["expose_global_message_channel"],
compatibilityFlags: ["expose_global_message_channel", "rpc_params_dup_stubs"],

// Define a backend worker to test server-side functionality. The tests will
// talk to it over a service binding. (Only the workerd client tests will talk
Expand All @@ -42,6 +42,7 @@ export default defineConfig({
{
name: "test-server-workerd",
compatibilityDate: '2025-07-01',
compatibilityFlags: ["rpc_params_dup_stubs"],
modules: [
{
type: "ESModule",
Expand Down
Loading