Skip to content

wit-bindgen 0.59: structurally-equal stream payloads across packages collide (websocket vs webrtc stream-message) #7

Description

@lann

Found wiring lann:websocket into the spike guest alongside lann:webrtc-datachannels.

The behavior. Both sibling packages define a record named stream-message with the identical shape { kind: enum { binary, string }, length: u32, data: stream<u8> }. wit-bindgen 0.59 canonicalizes stream payload types by structural equality (get_representative_type) on the assumption that structurally equal types resolve to the same Rust type — but it still generates one Rust type per interface module, so only the representative gets its StreamPayload impl and the other package's send-via-stream/receive-via-stream bindings fail to compile (the trait StreamPayload is not implemented for websocket::types::StreamMessage).

The workaround in-tree. The guest's generate! skips the two websocket streaming methods it doesn't call (guest/src/lib.rs, with the rationale at the site). skip matches raw function names, so the webrtc package's identically-named methods are unaffected.

To do:

  • Reproduce minimally and check newer wit-bindgen releases; report upstream to bytecodealliance/wit-bindgen if still present.
  • Remove the skip once fixed — or sooner if the endpoint ever wants the streaming surfaces (bounded-memory bulk transfer will, at which point this stops being a dormant workaround).

Note the trap this sets for the design: the family's packages deliberately mirror each other's shapes (the two stream-message records are twins by convention), which is exactly the condition that triggers the collision. Any future sibling with the same message-streaming idiom re-hits it.

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