process-compose icon indicating copy to clipboard operation
process-compose copied to clipboard

Panic when using "process logs" for a noisy process

Open dcarley opened this issue 1 year ago • 1 comments

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:

  1. process-compose up continues running.
  2. process-compose process logs exits successfully after reaching the latest log line.

Actual result:

  1. process-compose up exits 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
    
    
  2. process-compose process logs hangs 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.

dcarley avatar Jun 04 '24 10:06 dcarley

Thanks @dcarley for finding this edge case and letting me know! Fixed. Will be part of the next release.

F1bonacc1 avatar Jun 08 '24 15:06 F1bonacc1

@F1bonacc1 thanks for the quick response. Is the fix you mentioned pushed somewhere that I can try out?

dcarley avatar Jul 23 '24 14:07 dcarley

Fixed in v1.9.0

F1bonacc1 avatar Jul 25 '24 21:07 F1bonacc1