Skip to content

refactor(runtime): make duplex_stream_rx optional in RunOptions#680

Open
jaehafe wants to merge 1 commit intosupabase:mainfrom
jaehafe:refactor/optional-duplex-stream-rx
Open

refactor(runtime): make duplex_stream_rx optional in RunOptions#680
jaehafe wants to merge 1 commit intosupabase:mainfrom
jaehafe:refactor/optional-duplex-stream-rx

Conversation

@jaehafe
Copy link
Copy Markdown

@jaehafe jaehafe commented Apr 1, 2026

What kind of change does this PR introduce?

Refactor — resolves a TODO left by @nyannyacha

What is the current behavior?

RunOptions.duplex_stream_rx is required, so even workers that don't useDeno.serve() (e.g. pure computation, memory tests) must create a dummy mpsc::unbounded_channel just to satisfy RunOptionsBuilder::build().

// Before: unused channel created just to avoid build() error
let (_tx, duplex_stream_rx) = mpsc::unbounded_channel::<DuplexStreamEntry>();
user_rt.run(
    RunOptionsBuilder::new()
        .stream_rx(duplex_stream_rx) // not needed but required
        .build()
        .unwrap(),
)
ref: crates/base/src/runtime/mod.rs:353
// TODO(Nyannyacha): Make this as optional.
let Some(duplex_stream_rx) = duplex_stream_rx else {
    return Err(anyhow!("stream_rx can't be empty"));
};

What is the new behavior?

duplex_stream_rx is now Option in RunOptions. Workers that don't need networking can omit it entirely.

// After: no dummy channel needed
user_rt.run(
    RunOptionsBuilder::new()
        .build()
        .unwrap(),
)

Changes

  • RunOptions.duplex_stream_rx: UnboundedReceiverOption<UnboundedReceiver>
  • RunOptionsBuilder::build(): removed forced unwrap, passes Option through
  • DenoRuntime::run(): conditionally puts receiver into OpState via if let Some
  • op_net_accept: error message improved from "already used" to "not available"
  • Removed 5 dummy channel creations in tests

No behavioral change for production callers — managed.rs and user.rs always
provide a receiver. op_net_accept already handles None via try_take.

Additional context

All related tests pass (9/9): cargo test --package base

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