vvo / gifify

😻 Convert any video file to an optimized animated GIF.
ISC License
6.18k stars 313 forks source link

Maximum call stack size exceeded. #94

Open ghost opened 7 years ago

ghost commented 7 years ago

OS: Debian 8 x64 Node: v8.1.0 NPM: v5.0.3

Receiving this error:

RangeError: Maximum call stack size exceeded
    at emitOne (events.js:113:17)
    at ChildProcess.emit (events.js:210:7)
    at emitOne (events.js:115:13)
    at ChildProcess.emit (events.js:210:7)
    at emitOne (events.js:115:13)
    at ChildProcess.emit (events.js:210:7)
    at emitOne (events.js:115:13)
    at ChildProcess.emit (events.js:210:7)
    at emitOne (events.js:115:13)
    at ChildProcess.emit (events.js:210:7)

With this code:

const express = require('express');
const ydl = require('youtube-dl');
const gifify = require('gifify');
const fs = require('fs');

const app = express();
app.listen(80);

const video = ydl('https://www.youtube.com/watch?v=o-qK3u97iB0');

app.get('/', (req, res) => {
    gifify(video, { fps: 29.97 }).pipe(res);
});
Beanow commented 7 years ago

Same issue v2.4.0 gifify with giflossy. Ubuntu 16.04 based, node v6.9.4, npm 3.10.10

Beanow commented 7 years ago

I think the error is due to: https://github.com/vvo/gifify/blob/master/index.js#L49

  [ffmpeg, convert, gifsicle].forEach(function handleErrors(child) {
    child.on('error', gifsicle.emit.bind(gifsicle, 'error'));
    //...
  });

The gifsicle error event, would emit another gifsicle error.

vvo commented 7 years ago

Any of you can try to fix this? I am not yet using node v8.

Beanow commented 7 years ago

It's not v8 specific. Whenever the gifsicle object emits an error, you get an infinite loop of emitting more errors. You need to handle gifsicle's error events differently and it will fix this issue. What the error was that gifsicle emitted is a different issue.

vvo commented 7 years ago

Taking PRs to solve this.

Beanow commented 7 years ago

I'll pass since I haven't looked into it enough to see how you want error handling to work. I just butchered it to find my underlying problem was #95, but it could be a different problem for @UNST4BL3