Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

fix: don't stream when the append IPC is unavailable

neurot1cal5c5cab69034c
diff --git a/src/hooks/recorderHandle.test.ts b/src/hooks/recorderHandle.test.ts
index adb537008..3f16437e3 100644
--- a/src/hooks/recorderHandle.test.ts
+++ b/src/hooks/recorderHandle.test.ts
@@ -205,6 +205,26 @@ describe("createRecorderHandle", () => {
expect(blob.size).toBe(2);
});
+ it("buffers in memory when appendRecordingChunk is unavailable (version skew)", async () => {
+ const openRecordingStream = vi.fn(async () => ({ success: true }));
+ // appendRecordingChunk intentionally omitted to simulate renderer/main skew.
+ stubElectronAPI({ openRecordingStream });
+
+ const handle = createRecorderHandle({} as MediaStream, { mimeType: "video/webm" }, "rec.webm");
+ const fake = driver(handle);
+
+ fake.emit(new Blob(["a"]));
+ await tick();
+ fake.emit(new Blob(["b"]));
+ fake.stop();
+
+ const blob = await handle.recordedBlobPromise;
+ // Never even attempts to open the stream when it can't append to it.
+ expect(openRecordingStream).not.toHaveBeenCalled();
+ expect(handle.isStreaming()).toBe(false);
+ expect(blob.size).toBe(2);
+ });
+
it("discard closes the disk stream for a streamed recording", async () => {
const closeRecordingStream = vi.fn(async () => ({ success: true }));
stubElectronAPI({
diff --git a/src/hooks/recorderHandle.ts b/src/hooks/recorderHandle.ts
index d547bf9e2..e98000e6e 100644
--- a/src/hooks/recorderHandle.ts
+++ b/src/hooks/recorderHandle.ts
@@ -76,8 +76,14 @@ export function createRecorderHandle(
});
};
+ // Require BOTH stream IPC methods before attempting to stream. If only
+ // openRecordingStream exists (renderer/main version skew), streaming would
+ // open but every append would silently no-op, saving an empty file — so in
+ // that case fall through to in-memory buffering instead.
const openPromise: Promise<{ success: boolean; error?: string }> =
- fileName && api?.openRecordingStream
+ fileName !== undefined &&
+ typeof api?.openRecordingStream === "function" &&
+ typeof api?.appendRecordingChunk === "function"
? api.openRecordingStream(fileName)
: Promise.resolve({ success: false });