-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix: Additional bugs and code quality improvements #4210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d334718
6ce3e12
1f756b5
84724bf
9809d53
4c15280
82ab766
3d4e2a0
d8addbe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,8 @@ async function watchProgress(response: Response, progressCallback: (percentage: | |||||||
|
|
||||||||
| const contentLength = Number(response.headers.get('Content-Length')) || 0 | ||||||||
| let receivedLength = 0 | ||||||||
| const maxIterations = 100000 // Safety limit to prevent infinite loops | ||||||||
| let iterations = 0 | ||||||||
|
|
||||||||
| // Process the data | ||||||||
| const processChunk = async (value: Uint8Array | undefined) => { | ||||||||
|
|
@@ -14,6 +16,12 @@ async function watchProgress(response: Response, progressCallback: (percentage: | |||||||
| } | ||||||||
|
|
||||||||
| const read = async () => { | ||||||||
| // Safety check to prevent infinite recursion | ||||||||
| if (iterations++ > maxIterations) { | ||||||||
|
||||||||
| if (iterations++ > maxIterations) { | |
| if (iterations++ >= maxIterations) { |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] When aborting the read loop early, consider canceling the reader to free underlying resources. For example: await reader.cancel().
| console.error('Fetcher: Maximum iterations reached, stopping read loop') | |
| console.error('Fetcher: Maximum iterations reached, stopping read loop') | |
| await reader.cancel() |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -200,7 +200,10 @@ class WaveSurfer extends Player<WaveSurferEvents> { | |||||||
| if (initialUrl || (peaks && duration)) { | ||||||||
| // Swallow async errors because they cannot be caught from a constructor call. | ||||||||
| // Subscribe to the wavesurfer's error event to handle them. | ||||||||
| this.load(initialUrl, peaks, duration).catch(() => null) | ||||||||
| this.load(initialUrl, peaks, duration).catch((err) => { | ||||||||
| // Log error for debugging while still emitting error event | ||||||||
| console.error('WaveSurfer initial load error:', err) | ||||||||
|
Comment on lines
+204
to
+205
|
||||||||
| // Log error for debugging while still emitting error event | |
| console.error('WaveSurfer initial load error:', err) | |
| // Error is emitted via the 'error' event; consumers can handle logging if desired |
Copilot
AI
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Guard clearTimeout to avoid passing undefined in some TS/lib combinations and to be explicit: if (debounce) clearTimeout(debounce).
| clearTimeout(debounce) | |
| if (debounce) clearTimeout(debounce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Magic number for iteration cap. Extract to a named constant (e.g., MAX_STREAM_READ_ITERATIONS) or make it configurable to clarify intent and ease tuning.