Skip to content

Added live output (stream, WS and SSE) support - #123

Merged
msoap merged 10 commits into
masterfrom
live_output
Nov 25, 2026
Merged

msoap merged 10 commits into
masterfrom
live_output

Conversation

@msoap

@msoap msoap commented Nov 22, 2026

Copy link
Copy Markdown
Owner

fixes #33 and #97

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved issues can truncate CGI request input, falsely report command launch failures as successful exits, and emit streaming events above the documented 64 KiB limit.

3 open issues
What changed in this PR

Adds live command output to shell2http through per-endpoint streaming and Server-Sent Events (SSE), addressing the progress-display and continuous-log use cases in #33 and #97.

Changes:

  • Adds stream=1 and sse=1 endpoint options, immediate output flushing, and exit-code reporting.
  • Shares command preparation between output modes and adds cancellation on streaming-client disconnect or server shutdown.
  • Adds streaming and option-parsing tests, plus usage and lifecycle documentation.
File Description
stream.go Implements streaming responses, SSE framing, and line splitting.
stream_unix_test.go Tests streaming output, cancellation, timeout, and shutdown behavior.
shell2http.go Parses endpoint options, shares execution logic, and coordinates shutdown.
shell2http.1 Refreshes the manual with streaming and shutdown guidance.
shell2http_test.go Tests endpoint-option parsing and duplicate-path handling.
README.md Documents streaming configuration, examples, and limitations.
Makefile Excludes test files from errcheck.
http_middlewares.go Allows response controllers to unwrap the logging middleware.
exec_unix.go Defines Unix shutdown signals.
exec_other.go Defines the shutdown signal for non-Unix platforms.
doc.go Adds endpoint-option documentation and streaming examples.
config.go Adds the shared shutdown context for command cancellation.

Review effort: Balanced

Comment thread stream.go Resolved
Comment thread shell2http.go Resolved
Comment thread stream.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unbounded request-body reads and response writes can leave streaming handlers stuck after command exit or cancellation, preventing cleanup and lock release.

2 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Preserve split UTF-8 characters at the buffer limit

stream.go:183

If a write ends at exactly 64 KiB in the middle of a UTF-8 character, this emits the incomplete character immediately: the backtracking loop is skipped because end == len(lw.buf). For example, 65,535 ASCII bytes followed by the first byte of я, with its second byte in the next write, produces two SSE events containing replacement characters instead of я. Retain a newline-free buffer at exactly the limit until another byte arrives (or final flush), so the split can identify the character boundary.

3 resolved since last review

Review effort: Balanced

Comment thread shell2http.go Resolved
Comment thread stream.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread shell2http.go Resolved
Comment thread stream.go Resolved
Comment thread shell2http.1 Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed to evaluate UTF-8 boundary corruption and shutdown cleanup risks omitted from the published review.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@msoap
msoap requested a balanced review from Copilot November 25, 2026 20:02
@msoap msoap changed the title Added live output (stream and SSE) support Added live output (stream, WS and SSE) support Nov 25, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The WebSocket handler can block on stdin delivery and miss disconnect cancellation, while its preparation path can bypass the configured upload-size limit.

2 open issues

Review effort: Balanced

Comment thread websocket.go Resolved
Comment thread websocket.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed to evaluate subtle UTF-8 boundary and upload-cancellation interactions that can corrupt streamed output or prevent timely shutdown.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@msoap
msoap merged commit 62294f4 into master Nov 25, 2026
2 checks passed
@msoap
msoap deleted the live_output branch November 25, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Live output / flush

2 participants