Skip to content

Node doesn't exit after renderMedia()/renderFrames() unless closeBrowser() is called #21

Open

Description

@elwizard33

When I use the renderer API from a script, the process keeps running after the render and stitch are finished:

import path from 'node:path';
import { bundle } from '@rendiv/bundler';
import { selectComposition, renderMedia } from '@rendiv/renderer';

const serveUrl = await bundle({ entryPoint: path.resolve('src/index.tsx') });
const composition = await selectComposition(serveUrl, 'MyComp');
await renderMedia({ serveUrl, composition, outputLocation: 'out/out.mp4' });
console.log('done'); // prints, but the process never exits

It's the shared Chromium from openBrowser(). It stays open after the render, and its child processes keep the event loop alive. process.getActiveResourcesInfo() after done shows two ProcessWrap and six PipeWrap handles, and the process was still running 45 s later (master 6d6aca2, Windows 11, Node 24). Adding await closeBrowser() at the end fixes it, and the process exits right away. I first suspected Vite's esbuild from bundle() as well, but it isn't holding anything open.

I see the CLI already calls closeBrowser() in a finally, and I guess the browser is kept open on purpose so later renders are faster. So I think the simplest fix is to mention it in the docs, which don't cover closeBrowser() right now. I opened #28 for that. While I was there I also fixed the usage example: it imports bundle from @rendiv/renderer and passes compositionId, which renderMedia doesn't take.

If you'd rather handle it in code, something like a closeBrowserWhenDone option would work too.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions