Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (claude): cover the stale-generation getUserMedia rejection path

[._.]/ Adam Eivy7ff7ca35011b
diff --git a/client/src/hooks/useSingToScore.test.js b/client/src/hooks/useSingToScore.test.js
index d02d701fa3..83c3492942 100644
--- a/client/src/hooks/useSingToScore.test.js
+++ b/client/src/hooks/useSingToScore.test.js
@@ -148,6 +148,30 @@ describe('useSingToScore', () => {
expect(trackStop).toHaveBeenCalledOnce();
});
+ it('ignores a permission rejection that arrives after capture was already cancelled', async () => {
+ let rejectStream;
+ navigator.mediaDevices.getUserMedia = vi.fn(() => new Promise((_resolve, reject) => {
+ rejectStream = reject;
+ }));
+ const { result, unmount } = renderHook(() => useSingToScore({ tempo: 120, score: 'time: 4/4' }));
+
+ let startPromise;
+ act(() => { startPromise = result.current.start(); });
+ unmount();
+
+ // The pending getUserMedia request rejects only after cancel() already
+ // tore this attempt down (generation bumped). The stale-generation branch
+ // in the catch handler must swallow this quietly — no error surfaced, no
+ // stream to stop, no double release.
+ await act(async () => {
+ rejectStream(new Error('Permission denied'));
+ await startPromise.catch(() => {});
+ });
+
+ expect(result.current.error).toBeNull();
+ expect(trackStop).not.toHaveBeenCalled();
+ });
+
// `playback` REFUSES capture on iOS, and the transport-driven players declare
// it document-wide, so this hook has to claim `play-and-record` around its own
// getUserMedia rather than relying on nothing else having claimed first (#4131).