Repository navigation
Description
What happens
clerk api sends a request to Clerk's API. Before sending, it checks whether a request body was passed with -d or --file. If not, and stdin isn't a terminal, it reads stdin to the end as the body. When stdin is open but nothing ever writes to it or closes it, that read never finishes, and the command hangs before sending anything. This happens for GET requests too, which have no body.
Who hits it
Anyone running clerk api from a script, a CI job, a process manager, or an AI agent's tool runner that leaves stdin open. A terminal session isn't affected, because there stdin is a terminal and the CLI skips the read.
What the person experiences
- The command prints nothing and never exits.
- In CI, the job runs until it times out.
- An AI agent waits on a command that never returns.
How big a deal it is
- How often: unknown. It depends on how the caller starts the process. Many runners close stdin or attach
/dev/null, and some don't. - How bad when it happens: medium. There's no error message to search for, so it's hard to diagnose.
- Does it block them: yes, until they work around it. Workarounds today:
- redirect stdin:
clerk api /users </dev/null; - pass the body explicitly with
-d '<json>'or--file <path>. This also changes the default method from GET to POST, so pass-X GETwhen needed.
- redirect stdin:
Proposed fix
Read stdin as the body only when the caller asks for it, for example with --file - or -d @-, following the same rule --input-json - already uses. Keep piping working through that explicit option, and update the README example (cat payload.json | clerk api /users) to match. If keeping implicit piping is preferred, at least skip the stdin read for GET requests and add a short timeout before treating stdin as empty.
Where it goes: resolveBody in packages/cli-core/src/commands/api/index.ts, and packages/cli-core/src/commands/api/README.md.
Tests
- With stdin open and never written or closed,
clerk api /userssends its request and exits. - An explicit stdin body (whichever option is chosen) is still sent.
Reproduce
Run sleep 100 | clerk api /users. The command waits until sleep exits, without sending the request. The same command with </dev/null instead of the pipe returns at once.
Activity
pcbeingused333 commentedon Nov 4, 2026
I can reproduce the cause from the code:
resolveBodyinpackages/cli-core/src/commands/api/index.tsawaits stdin to EOF whenever-d/--fileis absent and stdin is not a TTY, including for GET requests. The issue lists two fixes, and they differ in behaviour: (a) read stdin only when asked (--file -/-d @-), which is a breaking change forcat payload.json | clerk api /users, or (b) keep implicit piping but skip the read for GET/HEAD and add a short timeout. Which would you prefer? I'm happy to send a PR with tests for either, plus the README update.This comment was prepared with the help of an AI assistant (Claude Code), and the author is responsible for it.