Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After running long running command, terminal seems to hang (with fish plugin franciscolourenco/done) #1917

Closed
blacktop opened this issue Jul 3, 2024 · 29 comments
Labels
upstream Issue is in an upstream project

Comments

@blacktop
Copy link
Collaborator

blacktop commented Jul 3, 2024

This has happened every time I've tested ghostty (so maybe it's a setting or meant to happen?)

However, what I do is open ghostty, update it to latest and then run tree . in my home dir and it dumps a FLOOD of text (very fast and performantly ;) )

When it finishes though it just hangs and doesn't let me type anything.

Screenshot 2024-07-03 at 1 54 25 PM

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

Running on macOS M1 Max MBP macOS 14.5

@mitchellh
Copy link
Contributor

Do you ever resize the terminal or is this from its default size?

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

Default size. I'll test resizing it now

@mitchellh
Copy link
Contributor

No need just curious since we know of some memory leaks on certain resize ops that are getting fixed soon. I’ll test this out soon!

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

ya resizing has no affect. To regain control and be able to continue using ghostty I have to Ctrl+C

So it kinda seems like ghostty isn't responding the the signals from the process that it's done and exited?

@mitchellh
Copy link
Contributor

That’d be a shell issue. Ghostty doesn’t do any process management besides spinning up the one process (shell) on start. What shell are you using?

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

fish; doesn't happen with iTerm, Terminal.app and VSCode terminal?

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

Just tested fish in iTerm2 again to make sure I wasn't lying and it has NO issue.

However, just tested zsh in Ghostty and it does NOT suffer from this issue. So I guess this is actually some kind of fish - ghostty issue?

@mitchellh
Copy link
Contributor

I just tried with fish and didn't have any issue. I noticed the program hangs while it asks for permissions (from macOS). Are those windows perhaps getting hidden from you somehow? Are you running a non-standard window manager or something? I noticed if I don't respond to it it just hangs until I press Ctrl+C. But, those popups are modal for me (created by macOS) and I can't avoid them in any way.

@mitchellh
Copy link
Contributor

As another approach, if you run tree . and when it hangs if you can grab a debug trace of where everything is I'd appreciate it. I don't know the exact steps to do that, but you should be able to attach to pids with the Xcode debugger.

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

Ya I get the TCC permissions window too and I select to decline to allow it access to other apps, then it continues on happily until the hang/freeze etc.

Again, with iTerm2 it doesn't happen, but I got the same TCC pop-up

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

I am using this fish setup - https://github.com/blacktop/dotfiles/blob/master/fish/setup.sh

I also have LockdownMode enabled, but doubt that'd have any effect.

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

Maybe it's the plugin franciscolourenco/done ? this is supposed to send a little notification to macOS when the 'long running process' finishes so you don't have to watch it etc Maybe it's doing something that ghostty isn't responding too or forwarding onto the OS and that's why it hangs?

@mitchellh
Copy link
Contributor

Maybe it's the plugin franciscolourenco/done ? this is supposed to send a little notification to macOS when the 'long running process' finishes so you don't have to watch it etc Maybe it's doing something that ghostty isn't responding too or forwarding onto the OS and that's why it hangs?

This very much sounds possible. Ghostty supports user notifications which it's presumably using and should work. User notifications SHOULD all be async... but perhaps something is blocking with it.

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 3, 2024

Removing plugin and trying again:

😆 no hang...

@blacktop blacktop changed the title After running long running command, terminal seems to hang After running long running command, terminal seems to hang (with fish plugin franciscolourenco/done) Jul 3, 2024
@mitchellh
Copy link
Contributor

Okay awesome. I think the best thing would be to reproduce that hang if possible while running Ghostty under Xcode and then pause it and we should get all the stack traces.

@uncenter
Copy link
Collaborator

uncenter commented Jul 5, 2024

Just wanted to say I've also been having this issue for a while now, same fish plugin! Mentioned it in Discord earlier - https://discord.com/channels/1005603569187160125/1005603569711452192/1196333773109870632 - but neglected to open an issue. Happy to help reproduce, let me try that suggestion to get the stack traces...

@uncenter
Copy link
Collaborator

uncenter commented Jul 5, 2024

I've having trouble with Nix building locally, are you able to get that stack trace @blacktop?

@uncenter
Copy link
Collaborator

uncenter commented Jul 6, 2024

I managed to build and reproduce the hang locally but not sure what to do / how to provide the stack trace.

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 6, 2024

2024-07-06 16:27:57.776143-0600 0x4f660    Error       0x0                  39480  0    ghostty: [com.mitchellh.ghostty:stream] unimplemented OSC callback: terminal.osc.Command{ .end_of_command = terminal.osc.Command.Command__struct_15485{ .exit_code = null } }
2024-07-06 16:27:57.776173-0600 0x4f660    Error       0x0                  39480  0    ghostty: [com.mitchellh.ghostty:stream] unimplemented OSC command: end_of_command
2024-07-06 16:28:16.579732-0600 0x4f1c7    Debug       0x0                  39480  0    ghostty: [com.mitchellh.ghostty:AppDelegate] application will save window state
2024-07-06 16:28:24.875155-0600 0x4f65c    Info        0x0                  39480  0    ghostty: [com.mitchellh.ghostty:font_codepoint_resolver] found codepoint 0xCA8 in fallback face=Arial Unicode MS

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 6, 2024

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
  * frame #0: 0x000000019e9861f4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x000000019e998b24 libsystem_kernel.dylib`mach_msg2_internal + 80
    frame #2: 0x000000019e98ee34 libsystem_kernel.dylib`mach_msg_overwrite + 476
    frame #3: 0x000000019e986578 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x000000019eaa6680 CoreFoundation`__CFRunLoopServiceMachPort + 160
    frame #5: 0x000000019eaa4f44 CoreFoundation`__CFRunLoopRun + 1208
    frame #6: 0x000000019eaa4434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #7: 0x00000001a924819c HIToolbox`RunCurrentEventLoopInMode + 292
    frame #8: 0x00000001a9247fd8 HIToolbox`ReceiveNextEventCommon + 648
    frame #9: 0x00000001a9247d30 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 76
    frame #10: 0x00000001a2303d68 AppKit`_DPSNextEvent + 660
    frame #11: 0x00000001a2af9808 AppKit`-[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 700
    frame #12: 0x00000001a22f709c AppKit`-[NSApplication run] + 476
    frame #13: 0x00000001a22ce2e0 AppKit`NSApplicationMain + 880
    frame #14: 0x000000010253296c ghostty`main at main.swift:14:5
    frame #15: 0x000000019e63e0e0 dyld`start + 2360
    ```

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 6, 2024

(lldb) bt
* thread #6, name = 'com.apple.NSEventThread'
  * frame #0: 0x000000019e9861f4 libsystem_kernel.dylib`mach_msg2_trap + 8
    frame #1: 0x000000019e998b24 libsystem_kernel.dylib`mach_msg2_internal + 80
    frame #2: 0x000000019e98ee34 libsystem_kernel.dylib`mach_msg_overwrite + 476
    frame #3: 0x000000019e986578 libsystem_kernel.dylib`mach_msg + 24
    frame #4: 0x000000019eaa6680 CoreFoundation`__CFRunLoopServiceMachPort + 160
    frame #5: 0x000000019eaa4f44 CoreFoundation`__CFRunLoopRun + 1208
    frame #6: 0x000000019eaa4434 CoreFoundation`CFRunLoopRunSpecific + 608
    frame #7: 0x00000001a242e188 AppKit`_NSEventThread + 144
    frame #8: 0x0000000103d055c0 libsystem_pthread.dylib`_pthread_start + 136
    ```

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 6, 2024

(lldb) bt
* thread #10
  * frame #0: 0x000000019e98eb70 libsystem_kernel.dylib`poll + 8
    frame #1: 0x0000000102a5a4a8 ghostty`Thread.PosixThreadImpl.spawn__anon_158740.Instance.entryFn at posix.zig:6480:31 [opt]
    frame #2: 0x0000000102a5a47c ghostty`Thread.PosixThreadImpl.spawn__anon_158740.Instance.entryFn [inlined] termio.Exec.ReadThread.threadMainPosix(ev=<unavailable>) at Exec.zig:1599:27 [opt]
    frame #3: 0x0000000102a5a438 ghostty`Thread.PosixThreadImpl.spawn__anon_158740.Instance.entryFn [inlined] Thread.callFn__anon_162116(args=<unavailable>) at Thread.zig:408:13 [opt]
    frame #4: 0x0000000102a5a438 ghostty`Thread.PosixThreadImpl.spawn__anon_158740.Instance.entryFn(raw_arg=<unavailable>) at Thread.zig:674:30 [opt]
    frame #5: 0x0000000103d055c0 libsystem_pthread.dylib`_pthread_start + 136
    ```

@blacktop
Copy link
Collaborator Author

blacktop commented Jul 6, 2024

If there's any other threads you think would be useful let me know, those were just the interesting looking ones

@mitchellh
Copy link
Contributor

Thanks, all of those threads are blocking in expected places... I don't see anything abnormal. The logs are also normal. I still plan on trying to repro this myself too.

@mitchellh
Copy link
Contributor

Okay I've installed done with fish and I can reproduce this only with terminal-notifier installed. I can actually reproduce this purely with terminal-notifier:

# This hangs!
$ echo "hello" | terminal-notifier -title "Hello" -sender "com.mitchellh.ghostty"

It looks like terminal-notifier itself is hanging for some reason.

@mitchellh
Copy link
Contributor

It looks like there is an upstream issue:

julienXX/terminal-notifier#301

@mitchellh
Copy link
Contributor

Going to close this as upstream and we should discuss in the done issue. I have a feeling this doesn't work since I can reproduce this with the AppStore bundle ID as well. If we can find a configuration in Ghostty to make this go away I'd be happy to take a look!

@mitchellh mitchellh added the upstream Issue is in an upstream project label Jul 8, 2024
@blacktop
Copy link
Collaborator Author

blacktop commented Jul 8, 2024

awesome triage 👍

zhming0 added a commit to zhming0/dotfiles that referenced this issue Jan 25, 2025
This is because a upstream issue in `terminal-notifier` caused long running command to hang.

See:
- julienXX/terminal-notifier#301
- ghostty-org/ghostty#1917
- ghostty-org/ghostty#2453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Issue is in an upstream project
Projects
None yet
Development

No branches or pull requests

3 participants