8000 Application limits.timeout is incorrect on streaming response · Issue #1626 · nginx/unit · GitHub
[go: up one dir, main page]

Skip to content

Application limits.timeout is incorrect on streaming response #1626

@Holi0317

Description

@Holi0317

Bug Overview

From documentation of limits.timeout,

Integer; request timeout in seconds. If an app process exceeds it while handling a request, Unit cancels the request and returns a 503 “Service Unavailable” response to the client.
https://unit.nginx.org/configuration/#configuration-proc-mgmt-lmts

What I understand from here is this timeout value should be the end-to-end lifetime of a request, not idle time between chunked responses / packets.

However, if I were to say I got a chunked response from server that is:

  1. Send 1st line
  2. Sleep 10sec
  3. Send 2nd line
  4. Sleep 10sec
  5. Send 3rd line, ending request

With a timeout of 15sec on unit configuration, I would expect the request to get cancelled on 15sec mark, and not receiving the 3rd line. Not sure what Unit should do to the http response here though because the header has already been sent and we can't just reverse course and replace it with 503 error.

Expected Behavior

Application timeout should be end-to-end timeout, not idle timeout.

Steps to Reproduce the Bug

The gist is in https://gist.github.com/Holi0317/215f2e0eadecf727fdf74a4efd10bda7. Using nodejs/hono for implementation here but it is affecting other languages as well. I first noticed this issue on PHP/Laravel environment in my work.

git clone https://gist.github.com/215f2e0eadecf727fdf74a4efd10bda7.git
cd 215f2e0eadecf727fdf74a4efd10bda7

docker build -t unittimeout .
docker run --rm -p 8080:80 unittimeout

# In another terminal
curl -v http://127.0.0.1:8080

The request will run for 20sec, with container log output:

Tue Jun 24 2025 15:14:27 GMT+0000 (Coordinated Universal Time) UwU 1
Tue Jun 24 2025 15:14:37 GMT+0000 (Coordinated Universal Time) UwU 2
Tue Jun 24 2025 15:14:47 GMT+0000 (Coordinated Universal Time) UwU 2

Environment Details

  • Target deployment platform: Docker
  • Target OS: Debian 12 in container
  • Version of this project or specific commit: 1.34.2
  • Version of any relevant project languages: node v22.16.0

Additional Context

I guess nxt_router.c is installing timeout handler nxt_router_app_timeout when receiving a new packet, without taking the time elapsed into account. But not really sure because I don't really know C.

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

      0