#18989·nushell

Handle to background job is dropped if `$env.PROMPT` closure is exited prematurely

Author: mkatychevCreated Sep 8, 2026Updated Sep 8, 2026
Labelsstatus:needs-triage

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

Image
sh-session
$ ff

Job 102 is re-frozen
q^C^[Error: nu::shell::error

  × Operation interrupted
   ╭─[/Users/mkatychev/.config/nu/prompt.nu:6:16]
 5 │ ]: int -> oneof<string, nothing> {
 6 │     let icon = match $in {
   ·                ──┬──
   ·                  ╰── This operation was interrupted
 7 │         1 => $one
   ╰────

~/Documents/rust/nushell-ci>

How to reproduce

  1. Have $env.PROMPT defined as a closure that is rather expensive, in this case calling gstat on a big repo in a big repo such as https://github.com/nushell/nushell/
  1. Start an CPU intensive task in another shell or session (like a release build of nushell with all features!).
  2. have background jobs frozen in a nu session and change directories rapidly to make a lot of $env.PROMPT calls
  3. ^C before $env.PROMPT_COMMAND has finished

Expected behavior

I expect errors to happen during CPU scheduling but not to have said errors result in dropping all references to background jobs

Configuration

key value
version 0.115.1
major 0
minor 115
patch 1
branch
commit_hash 798c55d19505fd52f205d7eb32a571b9d06ec9e6
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.95.0 (59807616e 2026-04-14)
rust_channel 1.95.0-aarch64-apple-darwin
cargo_version cargo 1.95.0 (f2d3ce0bd 2026-03-21)
build_time 2026-08-23 08:21:47 +00:00
build_rust_channel release
allocator standard
features default, helix, lsp, mcp, network, plugin, rustls-tls, sqlite, static-link-openssl, trash-support
installed_plugins gstat 0.115.1, query 0.115.1
experimental_options example=false, dc-glob=true, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=true, cell-path-types=true, background-completions=true