atuinsh/atuin

[Bug]: thread 'main' panicked with kind: WouldBlock, message: "Resource temporarily unavailable"

erszcz opened this issue · 2 comments

What did you expect to happen?

First of all, thanks for a great project - (almost) infinite shell history with stats and search is awesome!

I started using atuin yesterday. With Bash integration enabled, when I press the up arrow, I expect the history window to show up, so that I can browse my shell history.

What happened?

The window was printed to screen, but immediately followed with:

thread 'main' panicked at atuin/src/command/client/search/interactive.rs:862:60:
called `Result::unwrap()` on an `Err` value: Os { code: 35, kind: WouldBlock, message: "Resource temporarily unavailable" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The full shell result that I saw was:

 Atuin v18.1.0               <esc>: exit, <tab>: edit, <enter>: run, <ctrl-o>: inspect        history count: 18544
  Search │ Inspect
 ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │   12ms  35m ago rg "def label" deps/phoenix_html/lib/                                                         │
 │   12ms  34m ago rg "def textarea" deps/phoenix_html/lib/                                                      │
 │   32ms  34m ago rg "def textarea" deps/phoenix/lib/                                                           │
 │   16ms  34m ago rg "def label" deps/phoenix/lib/                                                              │
 │   8s    34m ago git diff                                                                                      │
 │   1s    34m ago git add -p                                                                                    │
 │   50ms  34m ago git commit -m "Book a time slot"                                                              │
 │   45ms  34m ago git l -5                                                                                      │
 │   1s    18m ago mix phx.gen.live                                                                              │
 │ 9 1s    14m ago mix phx.gen.live MyContext MyResource my_resources name:string age:integer                    │
 │ 8 12m   14m ago vim lib/calendlex_web/live/my_resource_live/form_component.ex                                 │
 │ 7 18ms   1m $ thread 'main' panicked at atuin/src/command/client/search/interactive.rs:862:60:
called `Result::unwrap()` on an `Err` value: Os { code: 35, kind: WouldBlock, message: "Resource temporarily unavailable" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
-bash: thread: command not found
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: Err: command not found
-bash: called: command not found
-bash: note:: command not found
11:35:06 erszcz @ x7 : ~/work/erszcz/calendlex (main *%)

Atuin doctor output

$ atuin doctor
Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

atuin:
  version: 18.1.0
  sync: null
shell:
  name: bash
  plugins:
  - atuin
  - bash-preexec
system:
  os: Darwin
  arch: x86_64
  version: 13.3.1
  disks:
  - name: Macintosh HD
    filesystem: apfs
  - name: Macintosh HD
    filesystem: apfs


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

I managed to catch a backtrace with RUST_BACKTRACE=1. Here's a full screen dump showing exactly what happens:

  1. I'm in an Elixir shell (actually an Erlang VM).
  2. I exit the shell by hitting Ctrl-C twice.
  3. Immediately once control is back to Bash I hit the up arrow, to restart the shell.
  4. Atuin shows up and crashes.

I think I saw the crash occurring by itself, too, but this time it happened immediately after the Erlang VM exited.

# this printout starts in Elixir shell run in Bash

Rebuilding...

Done in 51ms.
[debug] Live reload: lib/calendlex_web/live/my_resource_live/show.ex
[debug] Live reload: lib/calendlex_web/live/my_resource_live/index.ex
[debug] Live reload: lib/calendlex_web/live/my_resource_live/form_component.ex
[debug] Live reload: lib/calendlex_web/live/my_resource_live/index.html.heex
[debug] Live reload: lib/calendlex_web/live/my_resource_live/show.html.heex
Compiling 5 files (.ex)
warning: no route path for CalendlexWeb.Router matches "/my_resources/#{assigns.my_resource}/show/edit"
  lib/calendlex_web/live/my_resource_live/show.html.heex:5: CalendlexWeb.MyResourceLive.Show.render/1

warning: no route path for CalendlexWeb.Router matches "/my_resources/#{my_resource}/edit"
  lib/calendlex_web/live/my_resource_live/index.html.heex:21: CalendlexWeb.MyResourceLive.Index.render/1

Generated calendlex app

# I hit Ctrl-C twice here to exit the Elixir shell / Erlang VM

[error] GenServer #PID<0.878.0> terminating
** (Phoenix.Ecto.PendingMigrationError) there are pending migrations for repo: Calendlex.Repo. Try running `mix ecto.migrate` in the command line to migrate it
    (phoenix_ecto 4.5.1) lib/phoenix_ecto/check_repo_status.ex:67: Phoenix.Ecto.CheckRepoStatus.check_pending_migrations!/2
    (phoenix_ecto 4.5.1) lib/phoenix_ecto/check_repo_status.ex:31: anonymous fn/3 in Phoenix.Ecto.CheckRepoStatus.call/2
    (elixir 1.15.0) lib/enum.ex:2510: Enum."-reduce/3-lists^foldl/2-0-"/3
    (phoenix_ecto 4.5.1) lib/phoenix_ecto/check_repo_status.ex:30: Phoenix.Ecto.CheckRepoStatus.call/2
    (calendlex 0.1.0) lib/calendlex_web/endpoint.ex:1: CalendlexWeb.Endpoint.plug_builder_call/2
    (calendlex 0.1.0) deps/plug/lib/plug/debugger.ex:136: CalendlexWeb.Endpoint."call (overridable 3)"/2

# I hit the up arrow here to repeat the last command, i.e. restart the Elixir shell

 Atuin v18.1.0               <esc>: exit, <tab>: edit, <enter>: run, <ctrl-o>: inspect        history count: 18551
  Search │ Inspect
 ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │   1s    54m ago git add -p                                                                                    │
 │   50ms  54m ago git commit -m "Book a time slot"                                                              │
 │   45ms  54m ago git l -5                                                                                      │
 │   1s    38m ago mix phx.gen.live                                                                              │
 │   12m   34m ago vim lib/calendlex_web/live/my_resource_live/form_component.ex                                 │
 │   18ms  21m ago rm -rf lib/calendlex/my_context.ex lib/calendlex/my_context/ lib/calendlex_web/live/my_resourc│
 │   13ms  21m ago l1 test/calendlex                                                                             │
 │   8ms   21m ago rm test/calendlex/my_context_test.exs test/calendlex_web/live/my_resource_live_test.exs test/s│
 │   10ms  21m ago rmdir test/support/fixtures                                                                   │
 │ 9 51ms  21m ago git st                                                                                        │
 │ 8 0s    20m ago exit                                                                                          │
 │ 7 13ms  20m ago pdc                                                                                           │
 │ 6 $ thread 'main' panicked at atuin/src/command/client/search/interactive.rs:862:60:
called `Result::unwrap()` on an `Err` value: Os { code: 35, kind: WouldBlock, message: "Resource temporarily unavailable" }
stack backtrace:
   0: _rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <atuin::command::client::search::interactive::Stdout as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<ratatui::terminal::Terminal<ratatui::backend::crossterm::CrosstermBackend<atuin::command::client::search::interactive::Stdout>>>
   5: atuin::command::client::search::Cmd::run::{{closure}}
   6: atuin::command::client::Cmd::run_inner::{{closure}}
   7: tokio::runtime::scheduler::current_thread::Context::enter
   8: tokio::runtime::context::set_scheduler
   9: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
  10: tokio::runtime::context::runtime::enter_runtime
  11: tokio::runtime::runtime::Runtime::block_on
  12: atuin::main
note: Som
-bash: thread: command not found
-bash: command substitution: line 2: syntax error: unexpected end of file
-bash: Err: command not found
-bash: called: command not found
Invalid argument `backtrace:'
File does not exist or is not a regular file '--stack-root'.

             [--arch ARCH] [--ghc-variant VARIANT] [--ghc-build BUILD]
             [-j|--jobs JOBS] [--extra-include-dirs DIR] [--extra-lib-dirs DIR]
             [--custom-preprocessor-extensions EXT] [--with-gcc PATH-TO-GCC]
             [--with-hpack HPACK] [--[no-]skip-ghc-check] [--[no-]skip-msys]
             [--local-bin-path DIR] [--setup-info-yaml URL]
             [--[no-]modify-code-page] [--[no-]allow-different-user]
             [--[no-]dump-logs] [--color|--colour WHEN]
             [--snapshot-location-base URL] [--[no-]script-no-run-compile]
             [--resolver RESOLVER] [--compiler COMPILER] [--[no-]terminal]
             [--stack-colors|--stack-colours STYLES] [--terminal-width INT]
             [--stack-yaml STACK-YAML] [--lock-file ARG] COMMAND|FILE
-bash: 0:: command not found
-bash: 1:: command not found
-bash: 2:: command not found
-bash: atuin::command::client::search::interactive::Stdout: No such file or directory
-bash: syntax error near unexpected token `>'
-bash: 5:: command not found
-bash: 6:: command not found
-bash: 7:: command not found
-bash: 8:: command not found
-bash: 9:: command not found
-bash: 10:: command not found
-bash: 11:: command not found
-bash: 12:: command not found
-bash: note:: command not found
11:55:09 erszcz @ x7 : ~/work/erszcz/calendlex (main *%)
$

atuin/src/command/client/search/interactive.rs:862:60 is

execute!(self.stdout, PopKeyboardEnhancementFlags).unwrap();
now (following from the 18.1.0 tag)