Skip to content

nats pub "subject" "body" eats stdin? #1426

@alexbozhenko

Description

@alexbozhenko

Observed behavior

It looks like #1356 started to eat stdin(?), even when body is specified as cli argument. See repro below.

Expected behavior

nats publish
should not eat stdin?

Server and client version

server main (2.11.6)
client 0.2.2, comparing to 0.2.3

Host environment

No response

Steps to reproduce

0.2.2 sends all messages in bash while loop

curl -fSsL "https://binaries.nats.dev/nats-io/natscli/[email protected]"  | PREFIX=. sh
# while IFS=';' read -r topic message; do ./nats pub  "$topic" "$message"; done < repro.txt 
15:24:47 Published 20 bytes to "topic.62"
15:24:47 Published 20 bytes to "topic.83"
15:24:47 Published 20 bytes to "topic.60"
15:24:47 Published 19 bytes to "topic.33"
15:24:47 Published 20 bytes to "topic.36"

0.2.3 stops at the first one:

curl -fSsL "https://binaries.nats.dev/nats-io/natscli/[email protected]"  | PREFIX=. sh
# while IFS=';' read -r topic message; do ./nats pub  "$topic" "$message"; done < repro.txt
15:25:14 Published 20 bytes to "topic.62"

Cluade correctly suggested that the command is eating stdin. When giving /dev/null to nats, it works:

# while IFS=';' read -r topic message; do  ./nats pub "$topic" "$message" < /dev/null; done < repro.txt
15:40:33 Published 20 bytes to "topic.62"
15:40:33 Published 20 bytes to "topic.83"
15:40:33 Published 20 bytes to "topic.60"
15:40:33 Published 19 bytes to "topic.33"
15:40:33 Published 20 bytes to "topic.36"

cat repro.txt

topic.62;some_sort_of_msg_338
topic.83;some_sort_of_msg_114
topic.60;some_sort_of_msg_456
topic.33;some_sort_of_msg_75
topic.36;some_sort_of_msg_349

Metadata

Metadata

Assignees

Labels

defectSuspected defect such as a bug or regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions