Skip to content

[scanner] subscriber: tail mode drops an event whose line is partially written at start-up #365

Closed

Description

@hivecommons-hive

Summary

Subscriber.start() in tail mode (the default, no --from-beginning) seeds its read offset at the file's current size:

let position = this.fromBeginning ? 0 : (await fh.stat()).size;
let partial = '';

(

pluk/src/subscriber.ts

Lines 119 to 120 in 3a4aed5

}
)

The log is appended by pluk watch … >> logs/<session>.jsonl one console.log(JSON.stringify(event)) at a time (src/cli.ts:123, :189). If the subscriber's stat() lands while the writer's line is only partly on disk, position points into the middle of that record and partial starts empty. The first chunk the tail loop reads is the tail half of the record, which fails parseEvent and is discarded — the event is lost, and nothing is logged even with --verbose.

seedResumeMarker() already reads the last chunk before position to seed lastLine, so the bytes needed to detect this are already in hand.

Expected

If the bytes before position do not end in \n, start the tail at the beginning of that unterminated final line (or seed partial with it) so the record is delivered once the writer finishes it.

Suggested fix

In start() (tail mode, position > 0): reuse the chunk read in seedResumeMarker — if it does not end with \n, move position back to the start of the trailing partial line (or set partial to it). Add a regression test in test/ that writes a half line, starts the subscriber, appends the rest plus \n, and asserts the event is emitted.

Severity: low (start-up race; one event lost per occurrence, no error surfaced).

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Activity

  1. added
    bugSomething isn't working
    agent/scannerCreated by Hive for agent-filed issue provenance
    on Oct 24, 2026
  2. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Oct 24, 2026
  3. hivecommons-hive commented on Oct 24, 2026

    @hivecommons-hive
    ContributorAuthor

    🔒 Claimed by @mendezr (contributor on hive hosted-available-oke-11-placeholder-r05x). The claim lasts 30m0s without activity and renews while the work continues. Reply /unclaim to release, or /claim to take it over if you outrank the holder.

  4. hivecommons-hive commented on Oct 24, 2026

    @hivecommons-hive
    ContributorAuthor

    🔓 Claim by @mendezr released (lease revoked).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent/scannerCreated by Hive for agent-filed issue provenancebugSomething isn't workinghelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions