Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(meeting): ignore late stderr from inactive child in WindowsLoopbackAudioManager (#2016) (#2017)

Henry Su76ebb719df55
diff --git a/src/helpers/windowsLoopbackAudioManager.js b/src/helpers/windowsLoopbackAudioManager.js
index 1cfa309eb..ca5899e53 100644
--- a/src/helpers/windowsLoopbackAudioManager.js
+++ b/src/helpers/windowsLoopbackAudioManager.js
@@ -174,6 +174,7 @@ class WindowsLoopbackAudioManager {
});
child.stderr.on("data", (chunk) => {
+ if (this.process !== child) return;
this._consumeStderr(chunk, (message) => {
if (message.type === "start") {
finish(resolve);
diff --git a/test/helpers/windowsLoopbackAudioManager.test.js b/test/helpers/windowsLoopbackAudioManager.test.js
index 4cd1852e9..bcc4cc9cd 100644
--- a/test/helpers/windowsLoopbackAudioManager.test.js
+++ b/test/helpers/windowsLoopbackAudioManager.test.js
@@ -18,9 +18,12 @@ function setPlatform(platform) {
afterEach(() => setPlatform(originalPlatform));
-function loadManagerClass() {
+function loadManagerClass(mocks = {}) {
delete require.cache[managerModulePath];
Module._load = function loadWithMocks(request, parent, isMain) {
+ if (mocks[request]) {
+ return mocks[request];
+ }
if (request === "./debugLogger") {
return {
info() {},
@@ -233,3 +236,48 @@ test("live helper probe succeeds on this machine when the binary is present", as
assert.equal(parsed.ok, true);
assert.equal(parsed.supportsNativeCapture, true);
});
+
+test("stderr output from an inactive child is ignored after process change", async () => {
+ setPlatform("win32");
+ const { EventEmitter } = require("node:events");
+
+ const child = new EventEmitter();
+ child.stdout = new EventEmitter();
+ child.stderr = new EventEmitter();
+ child.stdin = new EventEmitter();
+ child.kill = () => {};
+
+ const MockedManager = loadManagerClass({
+ child_process: {
+ spawn: () => {
+ process.nextTick(() => {
+ child.stderr.emit("data", JSON.stringify({ type: "start" }) + "\n");
+ });
+ return child;
+ },
+ },
+ });
+
+ const manager = new MockedManager();
+ manager.resolveBinary = () => "C:\\helper.exe";
+ manager.getCapability = async () => ({ available: true });
+
+ const errors = [];
+ await manager.start({
+ onError: (err) => errors.push(err),
+ });
+
+ assert.equal(manager.process, child);
+
+ // Process is replaced or cleared (e.g. stopped)
+ manager.process = null;
+
+ // Stale stderr arrives from the old child
+ child.stderr.emit(
+ "data",
+ JSON.stringify({ type: "error", error: "stale process failure" }) + "\n"
+ );
+
+ assert.equal(errors.length, 0);
+ assert.equal(manager.stderrBuffer, "");
+});