hypercwd icon indicating copy to clipboard operation
hypercwd copied to clipboard

Open new tab take lots of time on Hyper 2.1.0-canary.3

Open ohardy opened this issue 6 years ago • 6 comments

Hi,

Its take lots of time to open a new tab or split with the last canary version of Hyper. No specific console log.

Any ideas ?

ohardy avatar Dec 12 '18 10:12 ohardy

This might be related to https://github.com/zeit/hyper/issues/2838

marwankhalili avatar Dec 13 '18 10:12 marwankhalili

Note sure. Everything was ok on canary 2 and if I disable hypercwd, I have no issue anymore

ohardy avatar Dec 13 '18 10:12 ohardy

Still the same with 2.1.0 stable for me.

hpohlmeyer avatar Dec 18 '18 16:12 hpohlmeyer

The problem is located in the setCwd function which contains an exec call to get the current working directory. In the current code it is assumed that exec returns a single string value but it actually returns 3 (error, stdout and stderr). The trim() called on the returned object therefore has no effect and fails to do so.

In the snippet below, promiseExec returns an object, so newCwd.trim() should actually be newCwd.stdout.trim().

const newCwd = await promiseExec(
    `lsof -p ${tab.pid} | grep cwd | tr -s ' ' | cut -d ' ' -f9-`);
  const cwd = newCwd.trim();

It doesn't seem like this repository is being actively maintained, so I decided to write a quick replacement plugin. It's located here hyper-samewd. Install with hyper i hyper-samewd

LeanderFS avatar Jan 02 '19 12:01 LeanderFS

@LeanderFS Thanks! I also changed the plugin to hypersamewd !

ruucm avatar Jan 03 '19 22:01 ruucm

The same thing happened. I'd tried to use hyper-samewd, but it had not worked. However, by rewriting the code of setCwd.js as following, somehow it worked well.

const newCwd = await promiseExec( // Specify LANG and not resolving domains
  `LANG=en_US.utf-8 lsof -n -p ${
    tab.pid
  } | grep cwd | tr -s ' ' | cut -d ' ' -f9-`
);

But it has not tested in various environments. My environment is macOS 10.14.2, Hyper 2.1.1, Japanese. Could you please test with other systems or languages? (Maybe my english is not good because I'm Japanese, sorry.)

MikuroXina avatar Jan 15 '19 09:01 MikuroXina