Skip to content

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

Description

@mkatychev

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
$ 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 798c55d
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

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

    status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions