Skip to content

check signals while printing values#14980

Merged
132ikl merged 1 commit intonushell:mainfrom
sgvictorino:print-interruption
Feb 7, 2025
Merged

check signals while printing values#14980
132ikl merged 1 commit intonushell:mainfrom
sgvictorino:print-interruption

Conversation

@sgvictorino
Copy link
Copy Markdown
Contributor

@sgvictorino sgvictorino commented Feb 2, 2025

Fixes #14960

User-Facing Changes

  • The output of non-streaming values can now be interrupted with ctrl-c:
~> use std repeat; random chars --length 100kb | repeat 2000 | str join ' ' | collect
<data omitted>^C
Error:
  × Operation interrupted
   ╭─[entry #1:1:61]
 1  use std repeat; random chars --length 100kb | repeat 2000 | str join ' ' | collect
   ·                                                             ────┬───
   ·                                                                 ╰── This operation was interrupted
   ╰────
  • When IO errors occur while printing data, nushell no longer panics:
 $ nu -c "true | print" | -

-Error:
-  x Main thread panicked.
-  |-> at crates/nu-protocol/src/errors/shell_error/io.rs:198:13
-  `-> for unknown spans with paths, use `new_internal_with_path`
+Error: nu::shell::io::broken_pipe
+
+  x I/O error
+  `->   x Broken pipe
+
+   ,-[source:1:1]
+ 1 | true | print
+   : ^^|^
+   :   `-| Writing to stdout failed
+   :     | Broken pipe
+   `----

@132ikl
Copy link
Copy Markdown
Member

132ikl commented Feb 2, 2025

thanks! i'd like to take a closer look at this when I get the chance

@132ikl 132ikl self-requested a review February 2, 2025 00:53
Copy link
Copy Markdown
Member

@132ikl 132ikl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! a couple quick thoughts here. I'm all for getting this into the release if possible.

also, I checked throughput of printing to stdout and it doesn't seem to be affected by this. great job!

Fixes #14960

# User-Facing Changes

- The output of non-streaming values can now be interrupted with ctrl-c:

```nushell
~> use std repeat; random chars --length 100kb | repeat 2000 | str join ' ' | collect
<data omitted>^C
Error:
  × Operation interrupted
   ╭─[entry #1:1:61]
 1 │ use std repeat; random chars --length 100kb | repeat 2000 | str join ' ' | collect
   ·                                                             ────┬───
   ·                                                                 ╰── This operation was interrupted
   ╰────
```

- When IO errors occur while printing data, nushell no longer panics:

```diff
 $ nu -c "true | print" | -

-Error:
-  x Main thread panicked.
-  |-> at crates/nu-protocol/src/errors/shell_error/io.rs:198:13
-  `-> for unknown spans with paths, use `new_internal_with_path`
+Error: nu:🐚:io::broken_pipe
+
+  x I/O error
+  `->   x Broken pipe
+
+   ,-[source:1:1]
+ 1 | true | print
+   : ^^|^
+   :   `-| Writing to stdout failed
+   :     | Broken pipe
+   `----
```
@132ikl
Copy link
Copy Markdown
Member

132ikl commented Feb 7, 2025

lgtm, thank you! I think we might be doing a patch release(?) so I won't merge this quite yet, but we should be good to go on this once we're ready to merge again

@132ikl 132ikl added status:wait-until-after-nushell-release A:signal-cancel Problems with how executions react to signals or attempts at cancellation (CTRL-C) notes:fixes Include the release notes summary in the "Bug fixes" section deprecated:pr-errors Deprecated: use A:error-handling, A:error-unhelpful, or A:error-silent-fail instead and removed status:wait-until-after-nushell-release labels Feb 7, 2025
@132ikl 132ikl merged commit 9420301 into nushell:main Feb 7, 2025
15 checks passed
@github-actions github-actions bot added this to the v0.103.0 milestone Feb 7, 2025
@sgvictorino sgvictorino deleted the print-interruption branch February 7, 2025 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:signal-cancel Problems with how executions react to signals or attempts at cancellation (CTRL-C) deprecated:pr-errors Deprecated: use A:error-handling, A:error-unhelpful, or A:error-silent-fail instead notes:fixes Include the release notes summary in the "Bug fixes" section

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: can't stop execution of open SQL_TABLE.db with Ctrl+C

3 participants