#POST requests hang forever

26 messages · Page 1 of 1 (latest)

silent hemlock
#

I'm trying to deploy my app using caddy as a reverse proxy. My Tanstack Start app (behind fastify) works fine using docker but as soon as I add caddy:

services:
  proxy:
    image: caddy:2-alpine
    restart: unless-stopped
    ports:
      - "8080:80"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile

  app:
    restart: unless-stopped
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - PORT=3000

where Caddyfile is:

:80 {
    encode gzip zstd

    reverse_proxy app:3000 {
        header_up Host {host}
        header_up X-Real-IP {remote_host}
        header_up X-Forwarded-For {remote_host}
        header_up X-Forwarded-Proto {scheme}
    }
}

then GET requests work fine (even files) but POST requests hang forever.

Does anyone have any idea what could cause this?

#

The POST request reaches fastify for sure (since I see a incoming request log in Fastify). It's a POST request made by Tanstack Query (using the native integration with Tanstack Start) to a server function. If I add a console.info to the start of the function it never gets executed.

#

Without the proxy the app works just fine (including post requests and even file uploads)

#

This is the Fastify server file. Probably not the source of the issue but might as well...

drowsy vigil
#

can you provide a full reproducer project that is easily runnable?

silent hemlock
drowsy vigil
#

otherwise its hard to track all the open topics

silent hemlock
#

Yup. I wasn't sure it was a bug

drowsy vigil
#

i dont know either

#

but if in doubt, just create an issue with a reproducer

#

we will eventually figure it out

silent hemlock
silent hemlock
#

Seems like Caddy is not the issue. Seems like toNodeHandler is the culprit. It's reproducible even in a regular pnpm build && pnpm start now

drowsy vigil
#

can you reproduce outside of start?

#

with just toNodeHandler and a dummy handler?

silent hemlock
#

What's the dummiest handler?

  fetch(request: Request) {
    return new Response();
  }
```?
drowsy vigil
#

thats very dummy!

#

might want to try a async version as well if that does not fail

silent hemlock
#

It's not reproducible neither with that nor with the async version of that

#

Seems like toNodeHandler + import handler from "@tanstack/react-start/server-entry" is the problem

#

POST requests hang forever

#

It's reproducible even without input data (although Tanstack Start seems to send something anyway)

drowsy vigil
#

It's reproducible
with or without start?

silent hemlock
#

with start

#

it's only reproducible when you mix toNodeHandler and @tanstack/react-start/server-entry