denoland/celld

Public

Cross-script service bindings drop WebSocket targets

MO

## Problem A router Worker calls a backend Worker through a service binding. The backend returns a WebSocket upgrade response. Celld sends the HTTP response but drops its WebSocket target. The browser closes the connection with code `1006`.

## Expected result The router must return the backend WebSocket to the client. The client must connect and exchange messages normally.

## Cause `op_svc_call_impl` calls:

```rust encode_http_response(response, false) ```

The `false` value removes `wsTarget` from the encoded response. The JavaScript harness also creates a new `Response` without `r.wsTarget`.

## Proposed fix https://github.com/mohamedalichelbi/celld/commit/fbebac2 Namely: Encode the target: ```rust encode_http_response(response, true) ```

Then add the target to the new response: ```js new Response(body, { status: r.status, headers: r.headers, __wsTarget: r.wsTarget, }) ```

  1. bartlomiejuclosed3 months ago on GitHub

  2. BA

    Thanks we already fixed it and will release this week in v0.3.0.

  3. bartlomiejureferenced 9c0ca09ef5d53 months ago on GitHub

  4. bartlomiejureferenced bc0e29cddf303 months ago on GitHub

  5. bartlomiejureferenced 89e4ffc53a143 months ago on GitHub

  6. tboserreferenced this in RpcTarget methods on a client-exported capability are lost across a Durable Object hop #1663 months ago on GitHub

  7. tboserreferenced this in WebSocket upgrade returned by the stateless Worker gets no handshake headers #1673 months ago on GitHub

  8. boliang-pinaireferenced this in Dynamic facet WebSocket upgrades lose their target; restoring it exposes missing facet event routing #2102 months ago on GitHub