Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

Recording: a recorder that crashes again later in a long meeting is restarted again; only a crash loop (a third crash within two minutes) stops the meeting

christianmat80f3571e68fd
diff --git a/app/src/main/capture.ts b/app/src/main/capture.ts
index 4b0c80cf..8315b25f 100644
--- a/app/src/main/capture.ts
+++ b/app/src/main/capture.ts
@@ -336,7 +336,7 @@ export async function recordingSettled(id: string, capMs = 30_000): Promise<void
clearTimeout(timer)
}
-/** Records while a meeting is recording: starts with it, stops with it, restarts once if the helper dies */
+/** Records while a meeting is recording: starts with it, stops with it, restarts the helper if it dies (crashPolicy) */
export function hookCapture(p: {
dirOf: (id: string) => string
onStart: (fn: (m: Pick<RecordingStart, 'id' | 'resume'>) => void) => unknown
diff --git a/app/src/main/crashPolicy.ts b/app/src/main/crashPolicy.ts
index 47d4e0f4..09d71b5d 100644
--- a/app/src/main/crashPolicy.ts
+++ b/app/src/main/crashPolicy.ts
@@ -1,8 +1,9 @@
/**
- * What to do when the audio helper dies mid-meeting: start it again once, as the next part of the same meeting's files
+ * What to do when the audio helper dies mid-meeting: start it again, as the next part of the same meeting's files
* (picking up at the meeting time where the last audio ended; the parts are joined into one file per track when
- * the meeting stops), and if it dies again, stop the meeting with the notes and audio so far kept.
- * One policy per meeting.
+ * the meeting stops). A long meeting can see a few unrelated crashes hours apart (a 2.5 h meeting stopped after its
+ * second), so only a crash loop gives up: a third crash within two minutes stops the meeting with the notes and audio
+ * so far kept. One policy per meeting.
*/
export type CrashDeps = {
/** starts a new helper for the next part, in the same meeting folder; may throw */
@@ -11,15 +12,22 @@ export type CrashDeps = {
hiccup(): void
/** tell the person recording stopped, and stop the meeting */
giveUp(): void
+ now?: () => number
}
+const LOOP_MS = 2 * 60_000
+const LOOP_RESTARTS = 2
+
export function createCrashPolicy(d: CrashDeps) {
- let restarted = false
+ const now = d.now ?? Date.now
+ let restarts: number[] = []
return {
ended(e: { crashed: boolean }): 'done' | 'restarted' | 'stopped' {
if (!e.crashed) return 'done'
- if (!restarted) {
- restarted = true
+ const t = now()
+ restarts = restarts.filter((r) => t - r < LOOP_MS)
+ if (restarts.length < LOOP_RESTARTS) {
+ restarts.push(t)
try { d.restart(); d.hiccup(); return 'restarted' } catch (err) { console.error('capture restart failed', err) }
}
d.giveUp()
diff --git a/app/test/capture.test.ts b/app/test/capture.test.ts
index 8039dc11..6b2bc3e4 100644
--- a/app/test/capture.test.ts
+++ b/app/test/capture.test.ts
@@ -353,11 +353,15 @@ describe('restart after a crash', () => {
await tick()
r.procs[0].exit(null, 'SIGKILL')
expect(r.starts[1]).toEqual({ dir: '/meetings/m1', opts: { part: 1, startMs: 3100 } })
- // a second crash after more audio: the meeting is stopped, and the parts are joined
+ // a second crash after more audio: the next part, from where that audio ended
r.procs[1].out.write(encodeFrame(pcm('them', 3100, new Array(3200).fill(0.1))))
await tick()
r.procs[1].exit(null, 'SIGKILL')
- expect(r.starts).toHaveLength(2)
+ expect(r.starts[2]).toEqual({ dir: '/meetings/m1', opts: { part: 2, startMs: 3300 } })
+ expect(r.stopped).toEqual([])
+ // a third within two minutes is a crash loop: the meeting is stopped, and the parts are joined
+ r.procs[2].exit(null, 'SIGKILL')
+ expect(r.starts).toHaveLength(3)
expect(r.stopped).toEqual(['m1'])
await recordingFinished('m1')
expect(r.joined).toEqual(['/meetings/m1'])
diff --git a/app/test/crashPolicy.test.ts b/app/test/crashPolicy.test.ts
index 04516694..d7f45b2e 100644
--- a/app/test/crashPolicy.test.ts
+++ b/app/test/crashPolicy.test.ts
@@ -3,12 +3,14 @@ import { createCrashPolicy } from '../src/main/crashPolicy'
const setup = (restartThrows = false) => {
const calls: string[] = []
+ const clock = { now: 0 }
const policy = createCrashPolicy({
+ now: () => clock.now,
restart: () => { calls.push('restart'); if (restartThrows) throw new Error('no helper') },
hiccup: () => calls.push('hiccup'),
giveUp: () => calls.push('giveUp'),
})
- return { policy, calls }
+ return { policy, calls, clock }
}
describe('crash policy', () => {
@@ -22,11 +24,19 @@ describe('crash policy', () => {
expect(policy.ended({ crashed: true })).toBe('restarted')
expect(calls).toEqual(['restart', 'hiccup'])
})
- it('a second crash stops the meeting', () => {
- const { policy, calls } = setup()
- policy.ended({ crashed: true })
+ it('a crash long after the last one restarts again, so a long meeting keeps recording (2.5 h meeting report)', () => {
+ const { policy, calls, clock } = setup()
+ for (let i = 0; i < 5; i++) { clock.now += 30 * 60_000; expect(policy.ended({ crashed: true })).toBe('restarted') }
+ expect(calls.filter((c) => c === 'giveUp')).toEqual([])
+ })
+ it('a crash loop (a third crash within two minutes) stops the meeting', () => {
+ const { policy, calls, clock } = setup()
+ expect(policy.ended({ crashed: true })).toBe('restarted')
+ clock.now += 20_000
+ expect(policy.ended({ crashed: true })).toBe('restarted')
+ clock.now += 20_000
expect(policy.ended({ crashed: true })).toBe('stopped')
- expect(calls).toEqual(['restart', 'hiccup', 'giveUp'])
+ expect(calls).toEqual(['restart', 'hiccup', 'restart', 'hiccup', 'giveUp'])
})
it('a restart that fails stops the meeting at once, with no hiccup', () => {
const { policy, calls } = setup(true)