andismith / grunt-responsive-images

Produce images at different sizes for responsive websites.
http://www.andismith.com/grunt-responsive-images/
MIT License
719 stars 96 forks source link

Maximum call stack size exceeded #86

Closed guillaumepalayer closed 9 years ago

guillaumepalayer commented 9 years ago

Hi @andismith,

I try to resize a few hundreds images (jpg, png) :smile: It perfectly works the first time i run the task grunt responsive_images:server.

Nevertheless, when i run the task for a second time, the error Warning: Maximum call stack size exceeded occurs – when newFilesOnly is running.

This is the output: image

Here is the grunt task:

responsive_images: {
      options: {
        quality: 80,
        sizes: [{
          name: 'xsmall',
          aspectRatio:false,
          upscale: true,
          width: 140
        },{
          name: 'small',
          upscale: true,
          width: 360
        },{
          name: 'medium',
          upscale: true,
          width: 640
        },{
          name: 'large',
          upscale: true,
          width: 1024
        }]
      },
      server: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>',
          src: ['img/sources/**/*.{jpg,jpeg,png}'],
          custom_dest: '<%= yeoman.app %>/img/{%= name %}'
        }]
      }
    },

and here is how i register the task

  grunt.registerTask('serve', function (target) {
    if (target === 'dist') {
      return grunt.task.run(['build', 'connect:dist:keepalive']);
    }

    grunt.task.run([
      'clean:server',
      'responsive_images:server',
      'newer:imagemin:server',
      'concurrent:server',
      'autoprefixer:server',
      'connect:livereload',
      'watch'
    ]);
  });

Any help much appreciate.

guillaumepalayer commented 9 years ago

PS: 'newFilesOnly' tries to check if 2561 files already exist on the disk. It's huge, isn't it ? But, i can't bypass this option given the number of files.

guillaumepalayer commented 9 years ago

Fix this issue by scheduling the "immediate" execution of callback after I/O events callbacks and before setTimeoutand setInterval – Read more here :octocat: : https://github.com/andismith/grunt-responsive-images/pull/87