Giter Site home page Giter Site logo

Comments (2)

amoilanen avatar amoilanen commented on July 18, 2024

Here you encountered two problems, both are Linux-specific, on my Windows machine everything works fine.

  • Running commands with arguments on Linux was failing

I fixed the problem in the revision db2bea2, also in the process I extracted the code that is responsible for running commands as a separate gist and tested it well separately https://gist.github.com/antivanov/20ee20b7a40995b1836c You can take a look.

Now it is possible to run commands with arguments in Linux.

However, when using the same code for running commands inside a Brackets extension some commands fail to run. In particular, from the example all the commands except for runCmdHandler("/home/anton/src/github/grunt-prepr", "grunt"); run successfully

This might be an issue with Brackets, need to further investigate. But in general simple commands should work. Things like git diff > ~/brackets.git.diff && gedit ~/brackets.git.diff & are not expected to work as of now (if for example, you want to see a quick git diff result).

  • When a command fails in Linux the Node server which runs inside Brackets fails and cannot be recovered.

For example, if you try to run a non-existing command the Node server will fatally fail somewhere at the low level. We have the following error handling code:

try {
    process = spawnProcess(dir, cmd);
  } catch (e) {
    console.error("Error trying to execute command '" + cmd + "' in directory '" + dir + "'");
    console.error(e);
    emit("error", e.message);
    emit("finished");
    return;
  }
process.stderr.on('data', function (data) {
    emit("error", data.toString('utf-8'));
  });

Error happens already somewhere after spawning a new process and we do not have enough control over error handling of that asynchronous code to prevent the Node server from crashing.

In Windows this is not a problem, all the errors are properly handled and the Node server does not crash. This looks like a Brackets bug.

from brackets-command-line-shortcuts.

amoilanen avatar amoilanen commented on July 18, 2024

From the developer guide this seems to be a known issue on the Brackets side https://github.com/adobe/brackets/wiki/Brackets-Node-Process:-Overview-for-Developers

Implement "safe mode" in Node core -- It is easy to write a domain that continually crashes Node. Right now, if we get two crashes within 5 seconds, we do not restart the Node process. The risk here is that the user will install an extension that repeatedly crashes Node, parts of Brackets will become unusable. For the things we have implemented now, this isn't a huge problem. But, if we start using Node for filesystem access, that means we could get into a state where the user's Node process crashes and he or she can't save their open documents.

And in fact if the Node process crashes the first time in Linux it does not get restarted. I will investigate this and maybe file an issue for Brackets

from brackets-command-line-shortcuts.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.