Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MaxListenersExceededWarning issue with @remotion/bundler and @remotion/renderer #1543

Closed
MatteoGauthier opened this issue Dec 6, 2022 · 9 comments
Labels
bug Something isn't working

Comments

@MatteoGauthier
Copy link
Contributor

MatteoGauthier commented Dec 6, 2022

Got an issue using @remotion/bundler and @remotion/renderer

here is the error logs

(node:80049) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node:80049) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:80049) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:80049) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@remotion+renderer@3.3.7_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/ExecutionContext.js:119
        throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(exceptionDetails));
              ^


Error: Evaluation failed: ReferenceError: __name is not defined
    at pptr://__puppeteer_evaluation_script__:1:387
    at new Promise (<anonymous>)
    at waitForPredicatePageFunction (pptr://__puppeteer_evaluation_script__:1:203)
    at ExecutionContext._ExecutionContext_evaluate (/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@remotion+renderer@3.3.7_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/ExecutionContext.js:119:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at WaitTask.rerun (/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@remotion+renderer@3.3.7_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/DOMWorld.js:186:23)

Node.js v18.12.1ELIFECYCLECommand failed with exit code 1.

and here is my render.ts file

import { bundle } from '@remotion/bundler';
import { getCompositions, renderMedia } from '@remotion/renderer';
import path from 'path';
import videosData from '../../data/videos.json';
import { RedditTiktokTestProps } from '../compositions/RedditTiktokTest';

const renderOne = async (
	redditVideo: RedditTiktokTestProps,
	bundleLocation: string,
	compositionId: string,
	entry: string
) => {
	// Parametrize the video by passing arbitrary props to your component.

	// Extract all the compositions you have defined in your project
	// from the webpack bundle.
	const comps = await getCompositions(bundleLocation, {
		// You can pass custom input props that you can retrieve using getInputProps()
		// in the composition list. Use this if you want to dynamically set the duration or
		// dimensions of the video.
		inputProps: redditVideo,
	});

	// Select the composition you want to render.
	const composition = comps.find((c) => c.id === compositionId);

	// Ensure the composition exists
	if (!composition) {
		throw new Error(`No composition with the ID ${compositionId} found.
  Review "${entry}" for the correct ID.`);
	}

	const currentDate = new Date().toISOString().split('T')[0];
	const outputLocation = `out/${currentDate}_${redditVideo.id}.mp4`;
	console.log('⏳ Attempting to render:', outputLocation);
	const startTimer = performance.now();

	await renderMedia({
		composition,
		serveUrl: bundleLocation,
		codec: 'h264',
		outputLocation,
		inputProps: redditVideo,
		imageFormat: 'jpeg',
		quality: 75,
		overwrite: true,
		concurrency: 6,
	});
	const stopTimer = performance.now();

	const inSeconds = (stopTimer - startTimer) / 1000;
	const rounded = Number(inSeconds).toFixed(3);
	console.log(`✅ Render done in ${rounded}s!`);
};

async function start() {
	const startTimer = performance.now();

	// The composition you want to render
	const compositionId = 'RedditTiktokTest';

	// You only have to do this once, you can reuse the bundle.
	const entry = 'src/index.ts';
	console.log('🔧 Creating a Webpack bundle of the video');

	const bundleLocation = await bundle(path.resolve(entry), () => undefined, {
		// If you have a Webpack override, make sure to add it here
		webpackOverride: (config) => config,
	});

	videosData.forEach(async (element: RedditTiktokTestProps) => {
		await renderOne(element, bundleLocation, compositionId, entry);
	});
	const stopTimer = performance.now();

	const inSeconds = (stopTimer - startTimer) / 1000;
	const rounded = Number(inSeconds).toFixed(3);
	console.log(`🎉 All videos have been rendered in ${rounded}s!`);
}

start();

Does someone can help me ?

@MatteoGauthier MatteoGauthier added the bug Something isn't working label Dec 6, 2022
@JonnyBurger
Copy link
Member

Hi Mattèo!

It looks like you are rendering all the videos at once, which might put the system under stress and can lead to crashes. From your code it could be that you did this unintentionally.

Try changing:

videosData.forEach(async (element: RedditTiktokTestProps) => {
		await renderOne(element, bundleLocation, compositionId, entry);
});

to:

for (const element of videosData) {
		await renderOne(element, bundleLocation, compositionId, entry);
}

This will render the videos in sequence rather than in parallel.

@MatteoGauthier
Copy link
Contributor Author

Hi @JonnyBurger thanks for your solution, I changed the loop to use a for, and I still have a problem but with puppeteer now...

/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/ExecutionContext.js:119
        throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(exceptionDetails));
              ^

Error: Evaluation failed: ReferenceError: __name is not defined
    at pptr://__puppeteer_evaluation_script__:1:387
    at new Promise (<anonymous>)
    at waitForPredicatePageFunction (pptr://__puppeteer_evaluation_script__:1:203)
    at ExecutionContext._ExecutionContext_evaluate (/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/ExecutionContext.js:119:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at WaitTask.rerun (/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/DOMWorld.js:186:23)
 ELIFECYCLE  Command failed with exit code 1.

@JonnyBurger
Copy link
Member

@MatteoGauthier Can you paste in here what your videosData is like? Maybe it is not serilalizable. Also, do you reference __name somewhere in your Remotion code?

@MatteoGauthier
Copy link
Contributor Author

MatteoGauthier commented Dec 6, 2022

@MatteoGauthier Can you paste in here what your videosData is like? Maybe it is not serilalizable. Also, do you reference __name somewhere in your Remotion code?

For sure, here is the json (nothing special here)

[
  {
    "videoUrl": "https://v.redd.it/3mcgfjp4m34a1/DASH_240.mp4?source=fallback",
    "title": "Idiot in an ambulance!",
    "id": "IdiotsInCars-zda02k"
  },
  {
    "videoUrl": "https://v.redd.it/zwq4heg7c44a1/DASH_720.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/zwq4heg7c44a1/DASH_audio.mp4",
    "title": "for being distracted watching the chaos that happened last night",
    "id": "IdiotsInCars-zde88x"
  },
  {
    "videoUrl": "https://v.redd.it/ygwoo7l4674a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/ygwoo7l4674a1/DASH_audio.mp4",
    "title": "Car swerves into motorcycle intentionally",
    "id": "IdiotsInCars-zdm9sj"
  },
  {
    "videoUrl": "https://v.redd.it/1i2049mxk64a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/1i2049mxk64a1/DASH_audio.mp4",
    "title": "Thought this sub was perfect for the stupid accident I had the other day. Lesson learnt for sure though. Very lucky to walk away.",
    "id": "IdiotsInCars-zdin8i"
  },
  {
    "videoUrl": "https://v.redd.it/mwoh22zx174a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/mwoh22zx174a1/DASH_audio.mp4",
    "title": "Police Chief in a golf cart",
    "id": "IdiotsInCars-zdt965"
  },
  {
    "videoUrl": "https://v.redd.it/shz6f7sj084a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/shz6f7sj084a1/DASH_audio.mp4",
    "title": "A normal Tuesday road rage in Chile",
    "id": "IdiotsInCars-zdr21e"
  },
  {
    "videoUrl": "https://v.redd.it/l9z3sdrsf54a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/l9z3sdrsf54a1/DASH_audio.mp4",
    "title": "After 10 min of straight honking I look out my window and see people holding up a major road in Brooklyn ... to load their van",
    "id": "IdiotsInCars-zdks2a"
  },
  {
    "videoUrl": "https://v.redd.it/3mxpetdsu74a1/DASH_240.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/3mxpetdsu74a1/DASH_audio.mp4",
    "title": "Biker VS Car road rage incident results in hectic car crash.",
    "id": "IdiotsInCars-zdx44o"
  },
  {
    "videoUrl": "https://v.redd.it/6t5wecgwz24a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/6t5wecgwz24a1/DASH_audio.mp4",
    "title": "ding-a-ling runs a red light, cuts me off and flips me the bird",
    "id": "IdiotsInCars-zd6syn"
  },
  {
    "videoUrl": "https://v.redd.it/hktxkglgn64a1/DASH_360.mp4?source=fallback",
    "title": "Truck with huge logs driving the wrong way",
    "id": "IdiotsInCars-zdj20u"
  },
  {
    "videoUrl": "https://v.redd.it/x0u75w57q44a1/DASH_720.mp4?source=fallback",
    "title": "Friends neighbor went reverse full throttle",
    "id": "IdiotsInCars-zdgh2a"
  },
  {
    "videoUrl": "https://v.redd.it/iacbzx6ar34a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/iacbzx6ar34a1/DASH_audio.mp4",
    "title": "Winter driving rule #37: Black Ice Takes Longer To Thaw On Overpasses Than On Roads.",
    "id": "IdiotsInCars-zdassy"
  },
  {
    "videoUrl": "https://v.redd.it/gg1oba84964a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/gg1oba84964a1/DASH_audio.mp4",
    "title": "Ignored no turn on red sign, and almost hit a pedestrian waiting to cross",
    "id": "IdiotsInCars-zdgoz0"
  },
  {
    "videoUrl": "https://v.redd.it/nz9zqrofo54a1/DASH_720.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/nz9zqrofo54a1/DASH_audio.mp4",
    "title": "Drivers like this is the reason I got a dash cam. She didn’t respond to my honking and when I passed her she was looking straight ahead and didn’t even seem to notice she almost caused an accident.",
    "id": "IdiotsInCars-zddail"
  },
  {
    "videoUrl": "https://v.redd.it/pr4b0sl6l44a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/pr4b0sl6l44a1/DASH_audio.mp4",
    "title": "Just a little road rage",
    "id": "IdiotsInCars-zdfnh7"
  },
  {
    "videoUrl": "https://v.redd.it/4fklv7r5b54a1/DASH_720.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/4fklv7r5b54a1/DASH_audio.mp4",
    "title": "everything is comical here",
    "id": "IdiotsInCars-zdjxdt"
  },
  {
    "videoUrl": "https://v.redd.it/2sg91wyiv44a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/2sg91wyiv44a1/DASH_audio.mp4",
    "title": "4 cars without lights in the span of 18 minutes....",
    "id": "IdiotsInCars-zd8q6p"
  },
  {
    "videoUrl": "https://v.redd.it/r5h0j3nzq64a1/DASH_1080.mp4?source=fallback",
    "audioUrl": "https://v.redd.it/r5h0j3nzq64a1/DASH_audio.mp4",
    "title": "I thought this psycho was going to hit me; then he passes illegally and hits his breaks. I turned off for safety.",
    "id": "IdiotsInCars-zdw1dk"
  },
  {
    "videoUrl": "https://v.redd.it/9w265mp2h34a1/DASH_480.mp4?source=fallback",
    "title": "Passed this fella before he got on the interstate",
    "id": "IdiotsInCars-zd96ch"
  }
]

and the repository https://github.com/MatteoGauthier/reddit-to-tiktok-remotion

sorry I close the issue by mistake 😅

@JonnyBurger
Copy link
Member

I don't know why you got this error specifically! I got a different one when running the script: No "src" passed.

From that I was able to fix it, sent you a PR!

@MatteoGauthier
Copy link
Contributor Author

MatteoGauthier commented Dec 6, 2022

@JonnyBurger Thanks a lot for your PR, I've merged it but I still have the same issue.

➜  reddit-to-tiktok-remotion git:(main) pnpm render         

> [email protected] render /Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion
> tsx ./src/script/reddit-videos.ts && tsx ./src/script/render.ts

🔧 Creating a Webpack bundle of the video
/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/ExecutionContext.js:119
        throw new Error('Evaluation failed: ' + (0, util_1.getExceptionMessage)(exceptionDetails));
              ^

Error: Evaluation failed: ReferenceError: __name is not defined
    at pptr://__puppeteer_evaluation_script__:1:387
    at new Promise (<anonymous>)
    at waitForPredicatePageFunction (pptr://__puppeteer_evaluation_script__:1:203)
    at ExecutionContext._ExecutionContext_evaluate (/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/ExecutionContext.js:119:15)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at WaitTask.rerun (/Users/matteogauthier/dev/draft/reddit-to-tiktok-remotion/node_modules/.pnpm/@[email protected]_biqbaboplfbrettd7655fr4n2y/node_modules/@remotion/renderer/dist/browser/DOMWorld.js:186:23)

I've reinstalled all node_modules

@JonnyBurger
Copy link
Member

@MatteoGauthier I'm afraid, this is a problem with tsx which uses ESBuild. Relevant issue: evanw/esbuild#1031

You can get it to work by using ts-node instead of tsx.

@MatteoGauthier
Copy link
Contributor Author

Thank you very much @JonnyBurger for this personalized assistance, you have helped me a lot ! 🙏

@JonnyBurger
Copy link
Member

Thanks, good luck with your bot! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants