mirror of
https://github.com/CopilotKit/CopilotKit.git
synced 2026-09-14 16:26:20 +08:00
50245bb4dd
Faithful node:22-slim repro: fd1 through the same awk process-substitution as entrypoint.sh, a Railway-capped drain reader, a uvicorn+CVDIAG-shaped flood, and the static no-log /api/health as victim. RED wedges (200->502, CPU->0, heartbeat frozen); the FIXED lane stays 200 throughout. run.sh asserts the outcome (exit 3/4/5 on a false result, proven). watchdog.sh runs the entrypoint public-guard loop verbatim and needle-anchors it against entrypoint.sh.
30 lines
1.0 KiB
JavaScript
30 lines
1.0 KiB
JavaScript
// Slow, rate-capped stdout reader — models Railway's downstream log drain cap
|
|
// (~500 logs/sec, "Messages dropped: 122" in the incident). By reading only
|
|
// CAP lines per TICK and pausing in between, it lets the upstream pipe buffer
|
|
// fill, which is what triggers the blocking write(2) in the producer.
|
|
//
|
|
// Sits at the end of the pipeline: server.mjs | awk '{...;fflush()}' | reader.mjs
|
|
// mirroring the real next start &> >(awk '{...; fflush()}') where awk's
|
|
// stdout is the container's Railway-consumed stdout.
|
|
|
|
import readline from "node:readline";
|
|
|
|
const CAP = parseInt(process.env.CAP || "50", 10); // lines drained per tick
|
|
const TICK = parseInt(process.env.TICK || "1000", 10); // ms per tick
|
|
|
|
let budget = CAP;
|
|
const rl = readline.createInterface({ input: process.stdin });
|
|
|
|
setInterval(() => {
|
|
budget = CAP;
|
|
process.stdin.resume();
|
|
}, TICK);
|
|
|
|
rl.on("line", () => {
|
|
if (--budget <= 0) {
|
|
// Stop draining until the next tick — this is the throttle that fills the
|
|
// upstream pipe.
|
|
process.stdin.pause();
|
|
}
|
|
});
|