Skip to content

Commit f9456db

Browse files
committed
fix: avoid buffering of messages
The while-loop was re-introduced, because without it 5-10 messages have been buffered before they were delivered.
1 parent 0fa4336 commit f9456db

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

image/signal-mqtt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,15 @@ subscribe_for_jsonrpc() {
113113
export MQTT_SUBSCRIBE_TOPIC
114114
printf %s "${MQTT_SUBSCRIBE_OPTIONS}" \
115115
| xargs mosquitto_sub -t "${MQTT_SUBSCRIBE_TOPIC}/#" -F %j \
116-
| jq --raw-output --compact-output 'to_jsonrpc(env.MQTT_SUBSCRIBE_TOPIC)' \
117-
| if [ "${LOG_JSONRPC:-false}" != 'true' ]; then
118-
cat -
116+
| while read -r json; do
117+
printf '%s\n' "${json}" \
118+
| jq --raw-output --compact-output 'to_jsonrpc(env.MQTT_SUBSCRIBE_TOPIC)' \
119+
| if [ "${LOG_JSONRPC:-false}" = 'true' ]; then
120+
{ log "$(tee /dev/fd/3)"; } 3>&1
119121
else
120-
while read -r line; do echo "${line}"; log "${line}"; done
122+
cat -
121123
fi
124+
done
122125
}
123126

124127
#######################################

0 commit comments

Comments
 (0)