Using WebSockets with PRC in Cloudflare Worker

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: }
[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: }
1 Reply
laurynas
laurynas5mo ago
running into the same issue here
Want results from more Discord servers?
Add your server