Panic when using "process logs" for a noisy process
Defect
Make sure that these boxes are checked before submitting your issue -- thank you!
- [x] Included the relevant configuration snippet
- [x] Included the relevant process-compose log (log location:
process-compose info) - [x] Included a [Minimal, Complete, and Verifiable example] (https://stackoverflow.com/help/mcve)
Version of process-compose:
% process-compose version
Process Compose
Version: v1.6.1
Commit: 3cd252d
Date (UTC): 2024-05-17T21:10:25Z
License: Apache-2.0
Discord: https://discord.gg/S4xgmRSHdC
Written by Eugene Berger
OS environment:
% uname -a
Darwin mba15.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64 arm Darwin
Steps or code to reproduce the issue:
With the following process-compose.yaml that simulates a noisy process:
version: "0.5"
processes:
noisy:
command: while true; do date; done
Started in one terminal with:
process-compose up --tui=false > /dev/null
And read the logs in another terminal with:
process-compose process logs noisy
Expected result:
process-compose upcontinues running.process-compose process logsexits successfully after reaching the latest log line.
Actual result:
-
process-compose upexits with an error:panic: send on closed channel goroutine 27 [running]: github.com/f1bonacc1/process-compose/src/api.(*PcApi).HandleLogsStream.func2({0x140000c4000?, 0x1c}) github.com/f1bonacc1/process-compose/src/api/ws_api.go:47 +0x48 github.com/f1bonacc1/process-compose/src/pclog.(*Connector).WriteString(0x14000259f48?, {0x140000c4000?, 0x140000bdd60?}) github.com/f1bonacc1/process-compose/src/pclog/log_observer_connector.go:24 +0x30 github.com/f1bonacc1/process-compose/src/pclog.(*ProcessLogBuffer).Write(0x14000259f20, {0x140000c4000, 0x1c}) github.com/f1bonacc1/process-compose/src/pclog/process_log_buffer.go:34 +0x224 github.com/f1bonacc1/process-compose/src/app.(*Process).handleInfo(0x1400033b6c0, {0x140000c4000, 0x1c}) github.com/f1bonacc1/process-compose/src/app/process.go:519 +0x148 github.com/f1bonacc1/process-compose/src/app.(*Process).handleOutput(0x1400033b6c0, {0x100bddea8?, 0x14000122740}, 0x14000055160) github.com/f1bonacc1/process-compose/src/app/process.go:510 +0x148 created by github.com/f1bonacc1/process-compose/src/app.(*Process).run.(*Process).getProcessStarter.func1 in goroutine 26 github.com/f1bonacc1/process-compose/src/app/process.go:192 +0x1c8 -
process-compose process logshangs until you ^C.
This close happens: https://github.com/F1bonacc1/process-compose/blob/3cd252df8d3a6852aea56efddf5f77eece7d5406/src/api/ws_api.go#L39
Before this write happens: https://github.com/F1bonacc1/process-compose/blob/3cd252df8d3a6852aea56efddf5f77eece7d5406/src/api/ws_api.go#L47
It doesn't happen every time and I can't reproduce it with a process that outputs logs less frequently.
Thanks @dcarley for finding this edge case and letting me know! Fixed. Will be part of the next release.
@F1bonacc1 thanks for the quick response. Is the fix you mentioned pushed somewhere that I can try out?
Fixed in v1.9.0