Description
The audio tool component fetches audio files without an AbortController. If a user navigates away mid-download, the request continues running in the background, wasting bandwidth.
Files to Update
surfsense_web/components/tool-ui/audio.tsx (line 91, inside the effect or callback that fetches audio)
What to Do
Wrap the fetch call with an AbortController and abort on cleanup:
// Inside the useEffect that fetches audio:
useEffect(() => {
const controller = new AbortController();
const loadAudio = async () => {
try {
const response = await fetch(src, { signal: controller.signal });
// ... rest of the audio processing
} catch (err) {
if (err instanceof DOMException && err.name === 'AbortError') {
return; // Expected when component unmounts
}
console.error('Failed to load audio:', err);
}
};
loadAudio();
return () => {
controller.abort();
};
}, [src]);
Reference: surfsense_web/components/homepage/github-stars-badge.tsx (lines 249–266) already uses this pattern correctly as an example.
Description
The audio tool component fetches audio files without an
AbortController. If a user navigates away mid-download, the request continues running in the background, wasting bandwidth.Files to Update
surfsense_web/components/tool-ui/audio.tsx(line 91, inside the effect or callback that fetches audio)What to Do
Wrap the fetch call with an
AbortControllerand abort on cleanup:Reference:
surfsense_web/components/homepage/github-stars-badge.tsx(lines 249–266) already uses this pattern correctly as an example.