devpod icon indicating copy to clipboard operation
devpod copied to clipboard

Infinite app instance spawns on macOS

Open srudolph-credera opened this issue 1 year ago • 13 comments

What happened?

I opened the DevPod application and it started spawning a new DevPod application every second or so without quitting the previous instance(s). I could only stop the process by quitting faster than the new windows could open.

What did you expect to happen instead?

I expected only a single DevPod instance to start.

How can we reproduce the bug? (as minimally and precisely as possible)

Since I took no other action other than opening the application, the issue must either be universal or tied to something about my particular setup/environment. Here's what I've already done to eliminate some environment differences (with no change in the app behavior):

  • I deleted DevPod.app and redownloaded it
  • I removed my entire ~/.devpod directory and restarted

Local Environment:

  • DevPod Version: v0.5.3
  • Operating System: mac
  • ARCH of the OS: ARM64

DevPod Provider:
N/A

Anything else we need to know?

I first installed DevPod yesterday and was using it without issue. I shutdown my laptop yesterday and started experiencing the issue the first time I opened DevPod this morning.

Peculiarities of my setup that might be relevant:

  • I installed DevPod to ~/Applications instead of /Applications
  • I am not on an admin user account
  • I manually added DevPod's CLI to my zshell PATH environment variable at $HOME/Applications/DevPod.app/Contents/MacOS

srudolph-credera avatar Feb 21 '24 16:02 srudolph-credera

Hey @srudolph-credera , thanks for opening the issue. This has been reported a couple of times by now and I am just not able to reproduce it :/ I've tried to setup a non-admin user and install DevPod into the $HOME/Applications folder. Works just fine

Are there any other pointers that could be relevant here?

pascalbreuninger avatar Feb 23 '24 06:02 pascalbreuninger

Thanks for taking a look at this! One thing you might try is coming back to that non-admin user account after a shutdown or a day has passed - DevPod worked fine for me initially as well.

As for other potential distinctions, I'm on a very recently setup M3 Max MacBook Pro for what it's worth - which has the upside I suppose of limiting how much cruft is around that could impact this (I did not use Migration Assistant). It's also a corporate machine, which could mean all sorts of typical enterprise software and configurations are around.

This has been a good opportunity for me to learn the DevPod CLI and thankfully I'm able to use that without issue, so it's just the GUI app here. I'd be happy to try running a debug version of the GUI (or launching it with an existing debug flag) if that's helpful!

srudolph-credera avatar Feb 23 '24 14:02 srudolph-credera

Thanks for the info! I'll leave my test user sitting and will try again tomorrow. If it still isn't reproducible I will have to look into things you'd typically lock down in enterprise macs :D

pascalbreuninger avatar Feb 23 '24 17:02 pascalbreuninger

Quick update @srudolph-credera: I've tried to wait a couple of days but wasn't able to repro. I'd appreciate any input on how exactly your machine is locked down

pascalbreuninger avatar Mar 04 '24 12:03 pascalbreuninger

I'm limited in what I can disclose that would be helpful (like the particular applications), but I believe the bulk of the lockdown is network related and I'd be happy to test specific things if you have something in particular that you think might be causing trouble.

This may be unrelated, but I do see a report of infinite window spawn in Tauri, could be an upstream issue: https://github.com/tauri-apps/tauri/issues/7681.

I also did a quick scan through the code - I'm completely new to Rust and to this project, but at first glance it looks like there is a new_main method that spans a new instance and there's an event handler that at least theoretically could be the cause of additional calls to that method: https://github.com/loft-sh/devpod/blob/f537b5719d2715405048df7dd63653fc3d50e1f2/desktop/src-tauri/src/ui_messages.rs#L69.

srudolph-credera avatar Mar 04 '24 14:03 srudolph-credera

Thanks for looking deeper into this! Tried to repro with firewall settings enabled but still no luck. Anyway, the rust method is definitely a possible source of this problem, let's try to work around it and then cut a new prerelease so you can verify

see #944

pascalbreuninger avatar Mar 05 '24 07:03 pascalbreuninger

I'll be happy to test it!

srudolph-credera avatar Mar 05 '24 14:03 srudolph-credera

New release over here, you'd need to install it manually though. Hope it works 🤞

pascalbreuninger avatar Mar 05 '24 15:03 pascalbreuninger

I just tested DevPod_macos_aarch64.app.tar.gz and unfortunately I see the same spawning issue. I was able to capture DevPod.log for you and this is what it looks like:

[2024-03-05][15:30:55][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:55][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:55][INFO][devpod_desktop] Run
[2024-03-05][15:30:55][INFO][devpod_desktop::server] Listening on 127.0.0.1:25842
[2024-03-05][15:30:56][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:56][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:56][INFO][devpod_desktop] Run
[2024-03-05][15:30:56][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:30:57][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:57][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:57][INFO][devpod_desktop] Run
[2024-03-05][15:30:57][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:30:57][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:57][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:57][INFO][devpod_desktop] Run
[2024-03-05][15:30:57][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:30:58][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:58][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:58][INFO][devpod_desktop] Run
[2024-03-05][15:30:58][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:30:59][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:59][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:59][INFO][devpod_desktop] Run
[2024-03-05][15:30:59][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:30:59][INFO][devpod_desktop] Setup application
[2024-03-05][15:30:59][INFO][devpod_desktop] Setup done
[2024-03-05][15:30:59][INFO][devpod_desktop] Run
[2024-03-05][15:30:59][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:31:00][INFO][devpod_desktop] Setup application
[2024-03-05][15:31:00][INFO][devpod_desktop] Setup done
[2024-03-05][15:31:00][INFO][devpod_desktop] Run
[2024-03-05][15:31:00][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:31:01][INFO][devpod_desktop] Setup application
[2024-03-05][15:31:01][INFO][devpod_desktop] Setup done
[2024-03-05][15:31:01][INFO][devpod_desktop] Run
[2024-03-05][15:31:01][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:31:01][INFO][devpod_desktop] Setup application
[2024-03-05][15:31:01][INFO][devpod_desktop] Setup done
[2024-03-05][15:31:01][INFO][devpod_desktop] Run
[2024-03-05][15:31:01][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)
[2024-03-05][15:31:01][INFO][devpod_desktop] Setup application
[2024-03-05][15:31:01][INFO][devpod_desktop] Setup done
[2024-03-05][15:31:01][INFO][devpod_desktop] Run
[2024-03-05][15:31:01][ERROR][devpod_desktop] Failed to start server: Address already in use (os error 48)

srudolph-credera avatar Mar 05 '24 15:03 srudolph-credera

hm okay, thanks @srudolph-credera. This looks like the setup process is being called time and time again... Not really sure why though, maybe it's really a tauri bug

pascalbreuninger avatar Mar 05 '24 16:03 pascalbreuninger

I tried building DevPod locally and ran into issues doing so within Multipass, but if you are able to make a build that logs the event/message passed into handle_msg plus any diagnostic info about Tauri's state, I'd be happy to run it!

srudolph-credera avatar Mar 06 '24 14:03 srudolph-credera

Another possibility mentioned in https://github.com/tauri-apps/tauri/issues/7681 is this Tauri plugin: https://github.com/tauri-apps/plugins-workspace/tree/v1/plugins/single-instance.

Edit: nevermind, macOS isn't supported by that plugin - https://github.com/tauri-apps/plugins-workspace/issues/287.

srudolph-credera avatar Mar 06 '24 14:03 srudolph-credera

Interesting new data point for this thread - I'm somehow able to launch DevPod from the terminal and, when I do, it opens either one or two GUI app instances (varies for some reason) but does not result in infinite DevPod app instances being spawned.

The oddity is that I don't understand why the GUI is being launched - in one terminal session running devpod or devpod --help just prints the usage information. In another session, running those commands launches the GUI app instance. The only difference when I print out env for both sessions is the TERM_SESSION_ID value. When I launch DevPod.app in Finder though, the infinite respawn still occurs.

(I'm currently running the latest v0.5.19 release)

srudolph-credera avatar Aug 27 '24 16:08 srudolph-credera