Skip to content

Commit 52b995e

Browse files
committed
fixed the AbortError issue in the AudioWaveform component. The error was occurring because of a race condition during cleanup when the component unmounts.
1 parent ad0e6ec commit 52b995e

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

apps/web/src/components/editor/audio-waveform.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,23 @@ const AudioWaveform: React.FC<AudioWaveformProps> = ({
7676

7777
return () => {
7878
mounted = false;
79+
// Use a safer cleanup approach to avoid AbortError
7980
if (wavesurfer.current) {
8081
try {
81-
wavesurfer.current.destroy();
82+
// Wrap in setTimeout to avoid race conditions with AbortController
83+
setTimeout(() => {
84+
try {
85+
if (wavesurfer.current) {
86+
wavesurfer.current.destroy();
87+
wavesurfer.current = null;
88+
}
89+
} catch (e) {
90+
console.warn("Error during delayed WaveSurfer cleanup:", e);
91+
}
92+
}, 0);
8293
} catch (e) {
83-
// Silently ignore destroy errors
94+
console.warn("Error during WaveSurfer cleanup:", e);
8495
}
85-
wavesurfer.current = null;
8696
}
8797
};
8898
}, [audioUrl, height]);

0 commit comments

Comments
 (0)