napolab / y-durableobjects

Real-time collaboration with Yjs on Cloudflare Workers using Durable Objects, eliminating Node.js dependencies. Inspired by y-websocket
https://yjs.napochaan.dev/
MIT License
116 stars 7 forks source link

feat: Use Cloudflare Workers RPC #20

Closed naporin0624 closed 3 months ago

naporin0624 commented 7 months ago

closed: #19

memo

PRC can communicate with workers and Durable Objects via serializable objects, but Response, including WebScoket, is not considered Serializable, so miniflare does not work. The same thing happens with v8 isolated.

✘ [ERROR] DOMException {
workers:dev: 
workers:dev:     stack: 'Error: Could not serialize object of type "WebSocket". This type does not support
workers:dev:   serialization.\n' +
workers:dev:       '    at null.<anonymous> (async
workers:dev:   file://[masked]/index.js:9652:35)\n' +
workers:dev:       '    at async dispatch
workers:dev:   (file://[masked]/compose.js:29:17)\n' +
workers:dev:       '    at async dispatch
workers:dev:   (file://[masked]/compose.js:29:17)\n' +
workers:dev:       '    at async cors2
workers:dev:   (file://[masked]/cors/index.js:65:5)\n' +
workers:dev:       '    at async dispatch
workers:dev:   (file://[masked]/compose.js:29:17)\n' +
workers:dev:       '    at null.<anonymous> (async
workers:dev:   file://[masked]/index.js:1006:25)\n' +
workers:dev:       '    at async jsonError
workers:dev:   (file://[masked]/json-error.ts:22:10)\n' +
workers:dev:       '    at async drainBody
workers:dev:   (file://[masked]/middleware-ensure-req-body-drained.ts:5:10)',
workers:dev:     code: 25,
workers:dev:     name: 'DataCloneError',
workers:dev:     message: 'Could not serialize object of type "WebSocket". This type does not support
workers:dev:   serialization.'
workers:dev:   }
changeset-bot[bot] commented 7 months ago

⚠️ No Changeset found

Latest commit: 6a7c705bac95f7e2cb642c3b100cb0d0227f526e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

cloudflare-workers-and-pages[bot] commented 7 months ago

Deploying yjs-worker with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6a7c705
Status: ✅  Deploy successful!
Preview URL: https://b3ce32d1.yjs-worker.pages.dev
Branch Preview URL: https://feat-worker-rpc.yjs-worker.pages.dev

View logs

naporin0624 commented 5 months ago

https://github.com/cloudflare/workerd/issues/2319