solid-start icon indicating copy to clipboard operation
solid-start copied to clipboard

[Bug?]: Response.clone: Body has already been consumed.

Open huseeiin opened this issue 9 months ago • 2 comments

Duplicates

  • [x] I have searched the existing issues

Latest version

  • [x] I have tested the latest version

Current behavior 😯

when trying to avoid trpc http network calls on the server, i get the error in the title

Expected behavior 🤔

no error

Steps to reproduce 🕹

https://github.com/huseeiin/solidstart-trpc-bug see src/trpc/client.ts

Context 🔦

No response

Your environment 🌎

System:
    OS: Linux 6.8 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (4) x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
    Memory: 2.85 GB / 7.65 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    npm: 10.8.1 - ~/.nvm/versions/node/v22.4.1/bin/npm
    pnpm: 10.6.2 - ~/.local/share/pnpm/pnpm
    bun: 1.2.3 - ~/.bun/bin/bun
  Managers:
    Apt: 2.4.11 - /usr/bin/apt
    Cargo: 1.80.1 - ~/.cargo/bin/cargo
    pip3: 22.0.2 - /usr/bin/pip3
  Utilities:
    CMake: 3.22.1 - /usr/bin/cmake
    Make: 4.3 - /usr/bin/make
    GCC: 11.4.0 - /usr/bin/gcc
    Git: 2.34.1 - /usr/bin/git
    Clang: 14.0.0 - /usr/bin/clang
    Curl: 7.81.0 - /usr/bin/curl
    OpenSSL: 3.0.2 - /usr/bin/openssl
  Virtualization:
    VirtualBox: 7.1.4 - /usr/bin/vboxmanage
  IDEs:
    Nano: 6.2 - /usr/bin/nano
    VSCode: 1.97.2 - /usr/bin/code
  Languages:
    Bash: 5.1.16 - /usr/bin/bash
    Java: 1.8.0_442 - /usr/bin/javac
    Perl: 5.34.0 - /usr/bin/perl
    Python3: 3.10.12 - /usr/bin/python3
    Rust: 1.80.1 - /home/hussein/.cargo/bin/rustc

huseeiin avatar Mar 11 '25 11:03 huseeiin

known issue, but unfortunately a no-fix on Start's side.

The issue is that TRPC's thrown error (TRPCError iirc) has a reference to its Request owner. Seroval will attempt to serialize it, but since Requests are one-time reads, it leads to that error.

The usual workaround here is to catch that error by yourself, and rethrowing an error that seroval supports (e.g. Error)

edit: https://github.com/huseeiin/solidstart-trpc-bug/blob/c3faa40c191c361e7435616642191ffcfb1dd0d8/src/trpc/client.ts#L13

This line here also shouldn't work at all. getRequestEvent will always be undefined.

lxsmnsyc avatar Mar 12 '25 14:03 lxsmnsyc

known issue, but unfortunately a no-fix on Start's side.

The issue is that TRPC's thrown error (TRPCError iirc) has a reference to its Request owner. Seroval will attempt to serialize it, but since Requests are one-time reads, it leads to that error.

The usual workaround here is to catch that error by yourself, and rethrowing an error that seroval supports (e.g. Error)

edit: https://github.com/huseeiin/solidstart-trpc-bug/blob/c3faa40c191c361e7435616642191ffcfb1dd0d8/src/trpc/client.ts#L13

This line here also shouldn't work at all. getRequestEvent will always be undefined.

should i close?

huseeiin avatar Mar 17 '25 11:03 huseeiin