Documentation Index
Fetch the complete documentation index at: https://mintlify.com/andresilva-cc/grafex/llms.txt
Use this file to discover all available pages before exploring further.
close() terminates the headless browser process that Grafex maintains across render calls. Because the browser is kept alive to amortize launch cost, it holds the Node.js event loop open — your script will not exit on its own until close() is called. Calling it is mandatory at the end of any script that uses render() or renderAll(), and should always be placed in a finally block so that it runs even when an error is thrown during rendering.
Signature
Behavior
Frees the browser process. Grafex uses Playwright internally to launch and manage a headless WebKit (or Chromium) browser.close() calls the underlying BrowserManager.close() method, which closes the Playwright browser context and terminates the OS-level browser process.
Clears the shared instance. After close() completes, the internal BrowserManager reference is set to null. The next call to render() or renderAll() detects this and automatically launches a fresh browser instance — there is no manual re-initialization step.
Safe to call multiple times. If currentManager is already null (because close() was already called), the function returns immediately without doing anything. This makes it safe to call unconditionally in finally blocks or cleanup handlers.
Examples
After
close() returns, the browser is fully stopped. If you call render() again, Grafex automatically creates a new browser instance — there is no need to call an “open” function explicitly.