zowe / zowe-cli

Zowe CLI
Eclipse Public License 2.0
108 stars 85 forks source link

Issue with new Daemon and Emacs start-process on Windows #1318

Open Trisk3lion opened 2 years ago

Trisk3lion commented 2 years ago

Hello

I'm using Zowe CLI with Emacs for enhancing my development workflow when developing mainframe applications with Emacs.

I have been using the "--daemon" mode together with the "zowex" binary for a while and it has been working great. But now after upgrading to the latest Zowe@next version (7.0.0-next.202202112312) I have problem using Emacs async functions start-process and async-shell-command the new zowe binary for using the daemon mode.

The problem is that I get no output from the command and process doesn't emit any events and just lives on doing (from Emacs point of view) nothing.

start-process is a Emacs function for starting an asynchronous process and is mainly used for running external programs without blocking Emacs. Its synchronous counterpart call-process works perfactly fine, as does commands which uses the underlying shell for running the programs, such as shell-command.

I know this is bit of nitche problem but I would love if you could look into it. Tell me if there is anything you need.

Zowe --version = 7.0.0-next.202202112312 Windows 10 20H2 GNU Emacs 29.0.50 (build 1, x86_64-w64-mingw32)

I have not tested if the same problems occur on Linux, but I'm going to try and see this weekend.

Edit: When using the regular binary, AppData\Roaming\npm\zowe, it works as normal.

t1m0thyj commented 2 years ago

What's the latest version of @zowe/cli@next that worked before you upgraded? For reference, 7.0.0-next.202202092037 is the @next version that precedes 7.0.0-next.202202112312. Or were you using an older version prior to upgrading?

I have been using the "--daemon" mode together with the "zowex" binary for a while and it has been working great.

I'm curious what version of the daemon binary you're using - we've renamed it from "zowex" to "zowe" and made several breaking changes to it since then. Newer versions of the daemon binary are available here, but I'd recommend running the command zowe daemon enable to make sure you get the right version for your CLI @next installation. This daemon enable command which we've recently added will extract the binary into the ~/.zowe/bin directory.

Trisk3lion commented 2 years ago

Thanks for the answer @t1m0thyj!

As for your questions:

  1. I'm not sure what version I was running before i upgraded but I think I installed it somewhere around July-August because I think I used the 0.21 version of the Zowex binary.
  2. I followed the newer instructions when upgrading and used zowe daemon enable so that the binary I'm using.

For what is worth it seems to work just fine on Linux (tested on Ubuntu WSL2), which makes me suspect that it has something to do with #1309 and how the daemon process is handled on windows.

I will continue to experiment and see what I find out!

Trisk3lion commented 2 years ago

I discovered another problem with the new Zowe Daemon and Emacs on Windows.

If you try to run zowe <any command> with the daemon binary before the daemon has started (the first time you run it), with call-process or shell-command you will hang Emacs indefinitely. The daemon seems to start but no output is sent to the sub process which Emacs creates. It is as if the output when starting the daemon is sent somewhere else.

But if you start the daemon beforehand, for example in cmd, it works just fine with call-process and shell-command (synchronous process commands).

t1m0thyj commented 2 years ago

This may be related to https://github.com/zowe/zowe-cli/issues/1277 - the way that child processes behave on Windows, a parent process cannot terminate until all its child processes have also terminated. Because of this we have a Windows-only step in our CI pipeline that starts the daemon background process before running tests. Otherwise we experience similar behavior to what you described, where a Jest test that runs zowe ... before the daemon has started will hang indefinitely.

github-actions[bot] commented 1 year ago

Thank you for creating a bug report. If you haven't already, please ensure you have provided steps to reproduce it and as much context as possible.