node-pty icon indicating copy to clipboard operation
node-pty copied to clipboard

Calling spawn with an invalid path causes .spawn to never return

Open Tyriar opened this issue 8 years ago • 2 comments
trafficstars

VS Code issues:

  • https://github.com/Microsoft/vscode/issues/31301
  • https://github.com/Microsoft/vscode/issues/31770

Tyriar avatar Aug 28 '17 18:08 Tyriar

Struggling to reproduce the hanging call in node-pty 😕. The following test ends up calling the same native API but throws a Node.js exception just fine:

  describe('WindowsTerminal', () => {
    describe('constructor', () => {
      describe('given an invalid launch path', () => {
        it('should fail gracefully', () => {
          // const term = new WindowsTerminal('');
          // const term = new WindowsTerminal('some_file_not_on_the_path');
          const term = new WindowsTerminal('C:\\WINDOWS\\System32', '', {
            name: "System32",
            cwd: "C:\\Users\\daimms.REDMOND\\Documents\\playground\\t",
          });
        });
      });
    });
  });
  23 passing (552ms)
  1 failing

  1) WindowsTerminal constructor given an invalid launch path should fail gracefully:
     Error: File not found: C:\WINDOWS\System32
      at new WindowsPtyAgent (lib\windowsPtyAgent.js:25:24)
      at new WindowsTerminal (lib\windowsTerminal.js:45:24)
      at Context.<anonymous> (lib\windowsTerminal.test.js:16:32)

Tyriar avatar Aug 28 '17 18:08 Tyriar

One way to be sure about this is to use which https://github.com/Tyriar/node-pty/issues/112 and validate this on the JS side. One perk here is a lot of C++ code can be removed from path_utils.cc

Tyriar avatar Aug 28 '17 18:08 Tyriar