Skip to content

JSON-RPC Serialization does not handle Array messages correctly #5665

@sharedRoutine

Description

@sharedRoutine

What version of Effect is running?

@effect/rpc: "0.71.1"

What steps can reproduce the bug?

See https://github.com/Effect-TS/effect/blob/main/packages/rpc/src/RpcSerialization.ts#L159, specifically the decodeJsonRpcRaw function.

When decoded is an Array, this function always returns an empty array (messages) and the code in the last line Array.isArray(decoded) ? decoded.map(decodeJsonRpcMessage) : [decodeJsonRpcMessage(decoded)] becomes unreachable.

What is the expected behavior?

Decoded messages should not be lost

What do you see instead?

When decoding JSON-RPC batch requests (arrays), all decoded messages are lost

Additional information

This can be tested by sending an Array of requests in a single HTTP Request to the RPC endpoint with RpcSerialization.layerJsonRpc({})

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions