Skip to content

Panics executing a closure received from the main process in a job #19147

Closed

Description

@weirdan

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

When a closure sent from the main process is executed within the context of a job Nushell panics

How to reproduce

❯ let queue = job spawn {
    job recv | do $in
}

❯ {sleep 200ms; touch 1.txt} | job send $queue
Error:   × Main thread panicked.
  ├─▶ at crates/nu-protocol/src/engine/engine_state.rs:1007:14
  ╰─▶ internal error: missing block
         0: <nu::Panic as core::fmt::Display>::fmt
         1: miette::handlers::graphical::GraphicalReportHandler::render_causes
         2: miette::handlers::graphical::GraphicalReportHandler::render_report_inner
         3: core::fmt::write
         4: <&std::io::stdio::Stderr as std::io::Write>::write_fmt
         5: nu::main::{{closure}}
         6: std::panicking::panic_with_hook
         7: std::panicking::panic_handler::{closure#0}
         8: std::sys::backtrace::__rust_end_short_backtrace::<std::panicking::panic_handler::{closure#0}, !>
         9: __rustc::rust_begin_unwind
        10: core::panicking::panic_fmt
        11: core::option::expect_failed
        12: nu_engine::closure_eval::ClosureEvalOnce::new_preserve_out_dest
        13: <nu_cmd_lang::core_commands::do_::Do as nu_protocol::engine::command::Command>::run
        14: nu_engine::eval_ir::eval_call
        15: nu_engine::eval_ir::eval_instruction
        16: nu_engine::eval_ir::eval_ir_block_impl
        17: nu_engine::eval_ir::eval_ir_block_inner
        18: nu_engine::eval_ir::eval_ir_block
        19: nu_engine::eval::eval_block
        20: nu_engine::eval::eval_block_with_early_return
        21: nu_engine::eval::CallEval::run
        22: nu_engine::closure_eval::ClosureEvalOnce::run_with_input
        23: std::sys::backtrace::__rust_begin_short_backtrace
        24: core::ops::function::FnOnce::call_once{{vtable.shim}}
        25: <std::sys::thread::unix::Thread>::new::thread_start

It also fails for this queue implementation, with a lengthier backtrace:

let queue = job spawn { 
    0.. | par-each { job recv | do $in | job send 0 } 
}

Interestingly enough, it works in the other direction: a closure received from a job can be executed in the main process.

Expected behavior

It should not panic. If the closure cannot be evaluated, it should throw a nushell error instead.

Configuration

key value
version 0.116.0
major 0
minor 116
patch 0
branch
commit_hash 2459fdd
build_os linux-x86_64
build_target x86_64-unknown-linux-musl
rust_version rustc 1.96.1 (31fca3adb 2026-06-26)
rust_channel 1.96.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.96.1 (356927216 2026-06-26)
build_time 2026-09-26 18:30:56 +00:00
build_rust_channel release
allocator standard
features dap, default, lsp, mcp, network, plugin, rustls-tls, sqlite, static-link-openssl, trash-support
installed_plugins formats 0.114.1, gstat 0.114.1, inc 0.114.1, plotters 0.1.5+0.103.0, polars 0.114.1, query 0.114.1
experimental_options example=false, dc-glob=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=false, cell-path-types=false

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions