Explainer videos and product demos made by your AI agent. Free and open source: a local voice (Kokoro), word timing (Whisper) and a canvas renderer turn a script into a narrated MP4.
JavaScript ai-agentsanimationcanvasclaude-codecodexexplainer-videoffmpegjavascriptkokoroproduct-demotext-to-speechvideo-generationwhisper
Exit by letting the event loop drain, so ONNX does not abort on macOS (#1)
meminens590fb4858496
diff --git a/bin/explainroo.js b/bin/explainroo.jsindex d4e0d10..5783dfe 100755--- a/bin/explainroo.js+++ b/bin/explainroo.js@@ -1,10 +1,19 @@#!/usr/bin/env nodeimport { main } from '../src/cli.js';+// Exit by letting the event loop drain, not with process.exit(). ONNX Runtime+// (voice and speech check models) aborts with "mutex lock failed" on macOS when+// process.exit() runs while its thread pool is alive. The unref'd timer only+// fires if some handle keeps the process up after main() is done.+const finish = (code) => {+ process.exitCode = code;+ setTimeout(() => process.exit(code), 5000).unref();+};+main(process.argv.slice(2)).then(- (code) => process.stdout.write('', () => process.exit(code ?? 0)),+ (code) => finish(code ?? 0),(e) => {process.stderr.write(`${e && e.stack ? e.stack : e}\n`);- process.exit(1);+ finish(1);},);diff --git a/test/cli-exit.test.js b/test/cli-exit.test.jsnew file mode 100644index 0000000..c40649f--- /dev/null+++ b/test/cli-exit.test.js@@ -0,0 +1,25 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import fs from 'node:fs';+import path from 'node:path';+import { spawnSync } from 'node:child_process';+import { fileURLToPath } from 'node:url';+import { cacheRoot, TTS_MODEL, ASR_MODEL } from '../src/models.js';++const bin = fileURLToPath(new URL('../bin/explainroo.js', import.meta.url));+const run = (args) => spawnSync(process.execPath, [bin, ...args], { encoding: 'utf8', timeout: 120000 });++test('the CLI passes on exit codes', () => {+ assert.equal(run(['nosuchcommand']).status, 2);+ assert.equal(run(['check', path.join(cacheRoot(), 'no-such-project')]).status, 1);+});++// ONNX Runtime aborts with "mutex lock failed" on macOS when process.exit()+// runs while the models are loaded. doctor --fetch loads both.+const cached = [TTS_MODEL, ASR_MODEL].every((m) => fs.existsSync(path.join(cacheRoot(), 'models', m)));+test('the CLI exits cleanly after loading the speech models', { skip: !cached && 'speech models not downloaded' }, () => {+ const r = run(['doctor', '--fetch']);+ assert.doesNotMatch(r.stderr, /mutex lock failed/);+ assert.equal(r.signal, null);+ assert.equal(r.status, 0, r.stderr);+});