Skip to content

Document the ledger order for sent writes - #3346

Merged
yohamta0 merged 2 commits into
mainfrom
fix-write-gate-ledger-order
Oct 27, 2026
Merged

yohamta0 merged 2 commits into
mainfrom
fix-write-gate-ledger-order

Conversation

@yohamta0

@yohamta0 yohamta0 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Main CI fails in internal/browserhost/writegate after the write gate merges. On #3337's and #3338's squash commits, TestGateRecordSendsWhatTheOperationMay and TestGateSendsSignInAndWhatAPersonDoes each lost their last event: the page saw its write blocked, but the next read of the gate's events did not contain it.

The cause is a real ordering bug in the gate, not in the tests. The gate told the browser what it decided, using Fetch.failRequest, Fetch.fulfillRequest or Fetch.continueResponse, and only then kept the event in its ledger. A reader that sees the outcome in the page and then reads the events can arrive between those two lines. This is what the step runtime does after an operation returns, and what the tests do after a fetch settles. Under load on a CI runner, it did.

The gate now keeps each event before it carries out the decision, for blocked writes and for every sent-write path. So an outcome the page sees is always readable.

Evidence

Test plan

  • go test -race -count=20 ./internal/browserhost/writegate/, both idle and with 12 CPU-bound processes running
  • golangci-lint for darwin and windows

Summary by CodeRabbit

  • Bug Fixes
    • Browser request outcomes are now recorded before the page is notified. This applies when requests are blocked and when responses succeed, fail, cannot be read, or cannot be retrieved. The outcomes themselves and the way responses are handled remain unchanged. This ordering helps ensure recorded activity reflects the result before it is relayed to the page.

The gate told the browser to block a write, or let a sent write's
answer through, before it kept the event. A reader that saw the
outcome in the page, such as the step after an operation returned,
could read the events before the gate kept that one, and under load it
did: CI saw the last blocked write missing. The gate now keeps the
event first, so the outcome a page sees is always already readable.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: e4d3a882-963c-4eb5-a904-d57ded5d1bb4
Commits

Reviewing files that changed from the base of the PR and between 741fed8 and 54a6abf.

Files selected for processing: 1
  • internal/browserhost/writegate/gate.go

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.

Walkthrough

The write gate changes when it records blocked-request and response events relative to browser continuation commands. Most covered paths record the event first; the readable-response path continues the response before recording its event.

Changes: Write gate event ordering

Layer / File(s) Summary
Ledger and continuation ordering
internal/browserhost/writegate/gate.go
Blocked requests and response-error, unreadable-response, and body-retrieval-failure events are recorded before continuation. For readable responses, the callback continues the response before recording the event.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • dagucloud/dagu#3342: Describes the same ledger-recording and continuation ordering changes in gate.go.
  • dagucloud/dagu#3337: Added response-stage pauses and response event recording in gate.go, which this change reorders.
  • dagucloud/dagu#3336: Added the paused and answered handlers that this change updates.
Merge Risk: Minimal · up to 54a6a

No actionable merge-blocking risk remains in the reviewed change.

Pre-merge checks: Passed 4
Check name Status Explanation
Description check Passed The description follows the template's main sections. It has a Summary that explains the ordering bug and the fix. It has a Changes-style explanation of the gate reordering, but it lacks a dedicated C…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main change: ledger ordering for sent writes. The implementation records events before the browser sees the outcome.
Full details: Description check

Explanation

The description follows the template's main sections. It has a Summary that explains the ordering bug and the fix. It has a Changes-style explanation of the gate reordering, but it lacks a dedicated Changes list with one item per line. It has no Related Issues section, and it does not reference a closing issue number. It lacks the Checklist, so the template's checklist items are not addressed. It includes a Test plan and Evidence, which go beyond the template. The required structure is partly present, and the missing parts are non-critical for a small code change, so the check passes.

Finishing Touches: 💡 1
⚔️ Resolve merge conflicts: 💡
  • Resolve merge conflict in branch fix-write-gate-ledger-order
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…-order

# Conflicts:
#	internal/browserhost/writegate/gate.go
@yohamta0 yohamta0 changed the title Keep a gate event before the page sees it Document the ledger order for sent writes Oct 27, 2026
@yohamta0
yohamta0 merged commit b74b19d into main Oct 27, 2026
21 checks passed
@yohamta0
yohamta0 deleted the fix-write-gate-ledger-order branch October 27, 2026 01:57
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