Skip to content

Interrupted Node sinks continue submitting writes when backpressure clears #7713

Closed

Description

@kitlangton

What version of Effect is running?

@effect/platform-node-shared v4 source at discovery base 243c72f001dd87385839c057af48f346abcf480b; publication base: 243c72f001dd87385839c057af48f346abcf480b. Reproduced on Node v26.5.0.

What steps can reproduce the bug?

Run Stream.make("a", "b") through NodeSink.fromWritable into a real Writable with highWaterMark: 1. Hold the first write callback until backpressure is established, interrupt the sink, then release the callback and allow Node's drain event to run.

Runnable regression and controls: the backpressure: endOnDone=$endOnDone, interrupted=$interrupted matrix, cancellation during drain dispatch: endOnDone=%s, and cancellation during resumed write: endOnDone=$endOnDone, backpressure=$backpressure. After branch push, run from its repository root:

pnpm test --run packages/platform/node-shared/test/NodeSink.test.ts

What is the expected behavior?

The already-submitted a may finish, but the interrupted sink must not submit b. This also holds when an earlier drain listener cancels the sink during the same dispatch. Cancellation inside a resumed write must prevent further submissions and listener registration.

What do you see instead?

The drain callback continues submitting data after the sink has exited with interruption. A callback selected before listener removal can still execute, and cancellation during a resumed write can leave another drain listener installed.

Additional information

The fixture uses native drain dispatch and public Fiber.interrupt or AbortController cancellation, not manually emitted events or a custom scheduler. The correction must invalidate pending callback work, not cancel bytes already owned by Node. Finalization errors are a separate issue.

Validation: Post-commit validation on 3a5be2dc6644: 16 distinct tests passed, 0 failed, 0 skipped. All listed PR Verification test commands, root pnpm lint-fix, root pnpm check, and committed/worktree whitespace checks passed; the worktree remained clean. The frozen paired base run at 243c72f001dd has 9 failing and 7 passing matched cases for this fix. Only the selected test files were run; integration and cluster suites were disabled.

Audit

Runtime correctness audit; intended label: audit.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions