Skip to content

[🐛 BUG]: A worker that fails on every request is never flagged unhealthy #209

Open

Description

@roxblnfk

No duplicates 🥲.

  • I have searched for a similar issue in our bug tracker and didn't find any solutions.

What happened?

A worker whose script fails on every request is never flagged unhealthy, so a broken deploy keeps answering 500 forever and never trips the failure handling. The same failure raised before the first request is caught: after five attempts Rapira logs worker keeps failing to boot; flagged unhealthy, answers 503 and exits with code 70.

This is what an app that boots lazily looks like when its container is broken: it takes the request, fails, answers 500 and exits non-zero. Symfony boots its kernel on the first request by default, as does any framework that initialises on demand; rapira-rs/symfony#1 boots the kernel before the loop partly to get the failure counted.

Cause: a cycle is classified only by whether the script received a job (rapira_worker.rs#L96-L102); once it has, the cycle is a recycle and the failure counter resets (#L111-L114). The script's exit status and the outcome of the jobs it served are not consulted.

Expected: a worker that repeatedly exits non-zero or bails out without completing a single non-errored request is flagged unhealthy. One bad request should not make a worker that has served successful requests unhealthy. Related to #195, which defines which failures count.

Version (rapira --version)

0.9.0 (Windows x86_64). The classification code is unchanged on main at 8e1f661.

How to reproduce the issue?

per-request.php, failing on every request:

<?php
\Rapira\handle_request(static function (): void {
    http_response_code(500);
    echo "kernel failed to boot\n";
});
exit(1);

before-request.php, the control, failing before any request:

<?php
exit(1);

per-request.toml (the control uses before-request.php and port 8712):

[http]
listen = "127.0.0.1:8711"

[http.pool]
entrypoint = "per-request.php"
mode = "worker"
processes = 1
  1. rapira serve per-request.toml, then send 10 requests: for i in $(seq 10); do curl -s -o /dev/null -w "%{http_code} " http://127.0.0.1:8711/; done
  2. Every request gets 500, nothing is logged, Rapira keeps running.
  3. The same with before-request.toml on port 8712: 503 503 503 503, then the connection is refused and Rapira exits with code 70.

Relevant log output

# per-request.toml: no log lines at all after 10 requests

# before-request.toml
2026-10-09T23:54:23.307700Z ERROR rapira: worker keeps failing to boot; flagged unhealthy

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions