Skip to content

fix(runtime): discard incomplete active TCP lines at close - #95

Merged
mremond merged 1 commit into
mainfrom
infinitary-batch/0992d21c
Nov 28, 2026
Merged

mremond merged 1 commit into
mainfrom
infinitary-batch/0992d21c

Conversation

@mremond

@mremond mremond commented Nov 28, 2026

Copy link
Copy Markdown
Member

Why

Nera treated an unfinished line as a complete packet when the peer closed, so an Erlang program could act on a truncated command.

What changed

  • On Linux and other systems using Nera’s event-based TCP reader, the program no longer receives an unfinished last line when the peer closes.
  • Complete lines still arrive with their line endings, as on BEAM.

Before and after

Before: Sending STATUS with a line ending, then an unfinished QUIT, delivered both commands as data before the close notification.

After: The same exchange delivers STATUS with its line ending, then the close notification; an unfinished line on its own delivers only the close notification.

This changes the sequence of messages an Erlang program receives, not a screen.

Checked

Live validation: Demonstrated for this version. 2 of 2 scenarios driven live in the product.

Scenario Result Evidence
Messages received when an active TCP line socket closes ✅ Passed live All four Linux cases matched both BEAM socket backends. The original native runtime sent an extra data packet in each case.
Alternate line reader at peer close (supplementary) ✅ Passed live The reader kept complete lines and reported close without delivering unfinished bytes. This did not test the messages sent to the program.
  • A native runtime that sends an unfinished packet after the close notification: The strengthened test rejected the late packet and passed ten consecutive runs on the fixed runtime.
  • Independent code review: Passed. The alternate reader still reads once when activated, so the review limited the documented close guarantee to the event-based reader.
  • Linux Rust and native suites: Rust: 2,264 passed, one ignored. Native: 550 passed, two existing external-integration skips.
How it was checked

The native fixture exercised active true and active once, preserved a preceding CRLF line, and checked for already queued messages after close without waiting.

Workspace Clippy, the CI change-map tests, allocator configuration, stacktrace order and native test storage passed.

Cross-object checks produced x86-64 Mach-O and AArch64 ELF objects; they do not establish native execution on those targets.

The workspace passed with the standard umask. The inherited group-writable umask exposes a separately tracked storage fixture defect.

Risk

Risk: low in every dimension.

Full risk assessment
Dimension Level Why
Blast radius low The change touches active TCP line reads at peer close.
Behavior low The close notification no longer comes with an unfinished line on the reactor path.
Undo low A revert restores the previous read behavior without moving data.
Evidence low Native mailbox traces match both BEAM backends in four real loopback cases.
Sensitivity low No sign-in, payment, production data, or signing material changes.
Novelty low The existing readers discard the incomplete buffer instead of delivering it.
Dependencies low No dependencies change.
Not done

Approval puts this change in the next batch. The batch merges only after its hosted integration and platform checks pass.

Passive line framing and buffered prefixes when re-arming a still-open socket are unchanged.

The alternate reader drops an unfinished line at end of input, but still reads only once per activation. Windows behavior was not exercised.

On Linux and other systems using Nera’s event-based TCP reader, the program no longer receives an unfinished last line when the peer closes.

Complete lines still arrive with their line endings, as on BEAM.
@github-actions github-actions Bot added this to the 0.1.1 milestone Nov 28, 2026
@mremond
mremond merged commit f3185e1 into main Nov 28, 2026
22 checks passed
@mremond
mremond deleted the infinitary-batch/0992d21c branch November 28, 2026 14:11
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.

1 participant