Skip to content

Can't interrupt bytes at with an infinite stream #13530

Closed

Description

@kaathewisegit

Describe the bug

It's impossible to interrupt an infinite binary stream, which is being sliced with bytes at.

How to reproduce

~> open /dev/urandom | into binary | bytes at ..10
^C^C^C^C

Expected behavior

I expected interrupts to work. They function normally with first and last:

~> open /dev/urandom | into binary | first 10
Length: unknown (stream) | printable whitespace ascii_other non_ascii
00000000:   c5 e1 dc 36  1c 4b f5 10  73 f8                      ×××6•Kוs×
~> open /dev/urandom | into binary | last 10
^CError:   × Operation interrupted
   ╭─[entry #5:1:1]
 1 │ open /dev/urandom | into binary | last 10
   · ──┬─
   ·   ╰── This operation was interrupted
   ╰────

Screenshots

No response

Configuration

key value
version 0.96.0
major 0
minor 96
patch 0
branch
commit_hash
build_os linux-x86_64
build_target x86_64-alpine-linux-musl
rust_version rustc 1.80.0 (051478957 2024-07-21) (Alpine Linux 1.80.0-r0)
cargo_version cargo 1.80.0 (376290515 2024-07-16)
build_time 2024-07-29 21:29:54 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, system-clipboard, trash
installed_plugins endecode 0.1.0

Additional context

No response

Activity

  1. added
    status:needs-triage
    on Aug 3, 2024
  2. added
    category:bug
    A:signal-cancel
    on Aug 3, 2024
  3. kaathewisegit commented on Aug 5, 2024

    @kaathewisegit
    ContributorAuthor

    I've tried tracking down the issue, and here's what I have:

    • bytes at uses operate from nu-cmd-base.

    • operate uses input.map.

    • input::map(&self) handles raw streams in the following way:

      PipelineData::ByteStream(stream, metadata) => {
          Ok(f(stream.into_value()?).into_pipeline_data_with_metadata(metadata))
      }

      Where into_value collects all of the input. I presume that's the point at which Nu hangs up on infinite streams.

  4. fdncred commented on Dec 6, 2024

    @fdncred
    Contributor

    Seems like it nearly works. What's not working is that open /dev/urandom | into binary | bytes at ..10 works the same as open /dev/urandom | into binary but I'm not using the f from that function so I'm sure I did something wrong.
    image

  5. WindSoilder commented on Dec 30, 2025

    @WindSoilder
    Contributor

    I can't reproduce it on latest version, and I think it can be closed

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

    A:signal-cancelcategory:bugstatus:needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions