Skip to content

Shared WebSocket RPC sessions in workerd seem to fail under large payload volume #158

@edmundhung

Description

@edmundhung

While working on a new feature that uses remote bindings to populate OpenNext cache entries into R2, we noticed that a shared WebSocket RPC session could fall over in workerd under large payload volume. I'm not confident whether the right fix belongs in capnweb or in workerd, but it seems to point more at the shared WebSocket session path than anything higher-level.

What seems to be happening is:

  • a long-lived shared WebSocket RPC session works fine in Node
  • the same pattern does not hold up in workerd once the payloads get large enough
  • if we avoid reusing one long-lived session and instead use fresh sessions in smaller batches, the problem goes away

I put together a repro in #157. In the failing test, workerd eventually OOMs and the client side ends with fetch failed / ECONNREFUSED:

workerd/jsg/setup.c++:38: fatal: V8 fatal error; location = Ineffective mark-compacts near heap limit; message = : allocation failed: JavaScript heap out of memory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions