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(renderer): handle the detached promises that can actually reject

Etienne Lescot135c360d2f80
diff --git a/src/components/ai-edition/ExportDialog.tsx b/src/components/ai-edition/ExportDialog.tsx
index 97ae481c0..901756989 100644
--- a/src/components/ai-edition/ExportDialog.tsx
+++ b/src/components/ai-edition/ExportDialog.tsx
@@ -316,7 +316,12 @@ export function ExportDialog({ open, onClose, document }: ExportDialogProps) {
action: {
label: t("exportDialog.showInFolder"),
onClick: () => {
- void window.electronAPI?.revealInFolder?.(pickedPath);
+ // `revealInFolder` is a bare ipcRenderer.invoke, so it rejects when
+ // the main handler throws. The export already succeeded — failing to
+ // open the folder is not worth a second toast, but it is worth a line.
+ void window.electronAPI?.revealInFolder?.(pickedPath).catch((err) => {
+ console.warn("[export] failed to reveal the file in its folder:", err);
+ });
},
},
});
diff --git a/src/components/ai-edition/Modals.tsx b/src/components/ai-edition/Modals.tsx
index ee0a89e43..739ca3f54 100644
--- a/src/components/ai-edition/Modals.tsx
+++ b/src/components/ai-edition/Modals.tsx
@@ -1512,7 +1512,13 @@ export function SourceTranscriptModal({
const v = videoRef.current;
if (!v) return;
if (v.paused) {
- void v.play();
+ // Same catch as VirtualPreview's: `play()` rejects on the autoplay policy
+ // or when a new load interrupts it, and `isPlaying` is driven by the
+ // element's own play/pause events — so a rejection leaves nothing to
+ // reconcile, it just must not escape as an unhandled rejection.
+ void v.play().catch(() => {
+ // swallow: rejection just means playback never started
+ });
} else {
v.pause();
}
@@ -1528,7 +1534,11 @@ export function SourceTranscriptModal({
const requestFullscreen = () => {
const v = videoRef.current;
if (!v) return;
- void v.requestFullscreen?.();
+ // Rejects when the gesture isn't accepted or the element can't go fullscreen.
+ // Nothing to reconcile — the document stays as it was.
+ void v.requestFullscreen?.().catch(() => {
+ // swallow: rejection just means we stayed windowed
+ });
};
return (
diff --git a/src/components/ai-edition/NewEditorShell.tsx b/src/components/ai-edition/NewEditorShell.tsx
index 56a220d0b..208942e27 100644
--- a/src/components/ai-edition/NewEditorShell.tsx
+++ b/src/components/ai-edition/NewEditorShell.tsx
@@ -465,7 +465,13 @@ export function NewEditorShell() {
const togglePlay = useCallback(() => {
if (!videoElement) return;
if (videoElement.paused) {
- void videoElement.play();
+ // Same catch as VirtualPreview's: `play()` rejects on the autoplay policy
+ // or when a new load interrupts it, and the store's `playing` flag is
+ // driven by the element's own play/pause listeners above — so a rejection
+ // leaves nothing to reconcile, it just must not escape unhandled.
+ void videoElement.play().catch(() => {
+ // swallow: rejection just means playback never started
+ });
} else {
videoElement.pause();
}
@@ -677,7 +683,9 @@ export function NewEditorShell() {
}
}
if (action === "record") {
- void window.electronAPI?.startNewRecording?.();
+ void window.electronAPI?.startNewRecording?.().catch((err) => {
+ console.warn("[editor] failed to start a new recording:", err);
+ });
}
resolve(choice);
})();
@@ -688,7 +696,9 @@ export function NewEditorShell() {
const handleNewRecording = useCallback(async () => {
const choice = await promptUnsaved("record");
if (choice !== "cancel") {
- void window.electronAPI?.startNewRecording?.();
+ void window.electronAPI?.startNewRecording?.().catch((err) => {
+ console.warn("[editor] failed to start a new recording:", err);
+ });
}
}, [promptUnsaved]);
diff --git a/src/components/ai-edition/v4/RecStage.tsx b/src/components/ai-edition/v4/RecStage.tsx
index 57a5185f1..af8405711 100644
--- a/src/components/ai-edition/v4/RecStage.tsx
+++ b/src/components/ai-edition/v4/RecStage.tsx
@@ -62,9 +62,16 @@ export function RecStage({
const [prefs, setPrefsState] = useState<RecordingPrefsState>(DEFAULT_PREFS);
useEffect(() => {
let cancelled = false;
- void window.electronAPI?.getRecordingPrefs?.().then((p) => {
- if (!cancelled && p) setPrefsState(p as RecordingPrefsState);
- });
+ void window.electronAPI
+ ?.getRecordingPrefs?.()
+ .then((p) => {
+ if (!cancelled && p) setPrefsState(p as RecordingPrefsState);
+ })
+ .catch((err) => {
+ // Bare ipcRenderer.invoke — rejects if the main handler throws. Keeping
+ // DEFAULT_PREFS is a fine outcome; an unhandled rejection is not.
+ console.warn("[rec-stage] failed to read the recording prefs:", err);
+ });
return () => {
cancelled = true;
};
@@ -72,7 +79,9 @@ export function RecStage({
const updatePrefs = (patch: Partial<RecordingPrefsState>) => {
setPrefsState((prev) => {
const next = { ...prev, ...patch };
- void window.electronAPI?.setRecordingPrefs?.(patch);
+ void window.electronAPI?.setRecordingPrefs?.(patch).catch((err) => {
+ console.warn("[rec-stage] failed to persist the recording prefs:", err);
+ });
return next;
});
};
@@ -112,7 +121,12 @@ export function RecStage({
// ── capture source (screen/window) ──────────────────────────────
const [source, setSource] = useState<ProcessedDesktopSource | null>(null);
useEffect(() => {
- void window.electronAPI?.getSelectedSource?.().then((s) => setSource(s ?? null));
+ void window.electronAPI
+ ?.getSelectedSource?.()
+ .then((s) => setSource(s ?? null))
+ .catch((err) => {
+ console.warn("[rec-stage] failed to read the selected source:", err);
+ });
}, []);
const [sourceModalOpen, setSourceModalOpen] = useState(false);
const [sourceTab, setSourceTab] = useState<"screen" | "window">("screen");
diff --git a/src/hooks/useScreenRecorder.ts b/src/hooks/useScreenRecorder.ts
index a40fa3a31..9724c27ef 100644
--- a/src/hooks/useScreenRecorder.ts
+++ b/src/hooks/useScreenRecorder.ts
@@ -208,15 +208,23 @@ export function useScreenRecorder(): UseScreenRecorderReturn {
// defaults every time startNewRecording() switches to the HUD window.
useEffect(() => {
let cancelled = false;
- void window.electronAPI?.getRecordingPrefs?.().then((prefs) => {
- if (cancelled || !prefs) return;
- setMicrophoneEnabled(prefs.micEnabled);
- if (prefs.micDeviceId) setMicrophoneDeviceId(prefs.micDeviceId);
- setWebcamEnabledState(prefs.camEnabled);
- if (prefs.camDeviceId) setWebcamDeviceId(prefs.camDeviceId);
- setSystemAudioEnabled(prefs.systemAudioEnabled);
- setCursorCaptureMode(prefs.cursorCaptureMode);
- });
+ void window.electronAPI
+ ?.getRecordingPrefs?.()
+ .then((prefs) => {
+ if (cancelled || !prefs) return;
+ setMicrophoneEnabled(prefs.micEnabled);
+ if (prefs.micDeviceId) setMicrophoneDeviceId(prefs.micDeviceId);
+ setWebcamEnabledState(prefs.camEnabled);
+ if (prefs.camDeviceId) setWebcamDeviceId(prefs.camDeviceId);
+ setSystemAudioEnabled(prefs.systemAudioEnabled);
+ setCursorCaptureMode(prefs.cursorCaptureMode);
+ })
+ .catch((err) => {
+ // Bare ipcRenderer.invoke — rejects if the main handler throws. Falling
+ // back to this hook's own defaults is acceptable; an unhandled rejection
+ // on every HUD mount is not.
+ console.warn("Failed to seed the recording prefs:", err);
+ });
return () => {
cancelled = true;
};
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index 28c499ed6..cd763bae1 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -933,7 +933,14 @@ export function useTimeline() {
// Don't await — the drop is already responsive; the probe will
// correct the clip when it lands.
if (asset.durationSec == null) {
- void probeAndCorrectClip(assetId, newClip.id, asset.originalPath);
+ // Detached on purpose (see above), so it needs its own handler: the probe
+ // itself only ever resolves, but it finishes with a `saveDocument`, and
+ // that THROWS on a failed write. Losing a background duration correction
+ // is survivable — the clip keeps its placeholder length; an unhandled
+ // rejection is not.
+ void probeAndCorrectClip(assetId, newClip.id, asset.originalPath).catch((err) => {
+ console.warn("[timeline] background duration probe failed to save:", err);
+ });
}
},
[saveDocument, probeAndCorrectClip],