Giter Club home page Giter Club logo

Comments (4)

sindresorhus avatar sindresorhus commented on July 28, 2024

Can't reproduce. Are you sure it's time-grunt? Try upgrading Node.

from time-grunt.

erikdubbelboer avatar erikdubbelboer commented on July 28, 2024

I found the issue. Most tasks in grunt are synchronous. In our case our default task is a big synchronous task which does a lot of sync file IO (grunt.file.write etc).
In node when nothing catches SIGINT it just terminates the process immediately. But when time-grunt catches SIGINT node will dispatch the javascript code to run for it.
The problem is that our big task (any many others like grunt-uglify or grunt-contrib-cssmin) are all synchronous and don't yield for the SIGINT code to run.

This can be seen with this simple Gruntfile:

module.exports = function(grunt) {
  require('time-grunt')(grunt);

  grunt.registerTask('default', function() {
    console.log('testing...');
    var end = Date.now() + 4000;
    while (Date.now() < end) {
      grunt.file.write('test', 'test');
    }
    console.log('done');
  });
};

Try killing it with Ctrl+C and you'll see it only gets killed after the task completes. Now remove time-grunt to remove the SIGINT handler, try killing it again, and you'll see it is killed immediately.

So in conclusion: because most grunt tasks are written in a synchronous way there is nothing time-grunt can do about this issue. Except for maybe document this behavior.

from time-grunt.

erikdubbelboer avatar erikdubbelboer commented on July 28, 2024

I would suggest removing

time-grunt/index.js

Lines 147 to 149 in d850113

process.on('SIGINT', function () {
process.exit();
});
seeing as people who use Ctrl+C probably aren't interested in seeing the elapsed execution time anyways.

For now the workaround we're using is:

  var processOn = process.on;
  process.on = function(what,cb) {if(what!=='SIGINT'){processOn.call(process,what,cb);}};
  require('time-grunt')(grunt);
  process.on = processOn;

from time-grunt.

sindresorhus avatar sindresorhus commented on July 28, 2024

Closing as this project is deprecated because Grunt is no longer actively maintained, so it doesn't make sense for me to maintain this project either.

from time-grunt.

Related Issues (20)

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.