-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: prevent silent failures when releasing stream reader locks #3397
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
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -464,5 +464,10 @@ async function* streamToAsyncIterator<T>(stream: ReadableStream<T>): AsyncIterab | |||||||||||||||||
| function safeReleaseLock(reader: ReadableStreamDefaultReader<any>) { | ||||||||||||||||||
| try { | ||||||||||||||||||
| reader.releaseLock(); | ||||||||||||||||||
| } catch (error) {} | ||||||||||||||||||
| } catch (error) { | ||||||||||||||||||
| if (debug) { | ||||||||||||||||||
| // fallback if no logger available | ||||||||||||||||||
| console.warn("Failed to release stream reader lock", error); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+468
to
+471
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Undefined Same issue as in
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
464
to
473
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚩 Design consideration: Even after fixing the Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -212,5 +212,10 @@ async function* streamToAsyncIterator<T>(stream: ReadableStream<T>): AsyncIterab | |||||||||||||||||
| function safeReleaseLock(reader: ReadableStreamDefaultReader<any>) { | ||||||||||||||||||
| try { | ||||||||||||||||||
| reader.releaseLock(); | ||||||||||||||||||
| } catch (error) {} | ||||||||||||||||||
| } catch (error) { | ||||||||||||||||||
| if (debug) { | ||||||||||||||||||
| // fallback if no logger available | ||||||||||||||||||
| console.warn("Failed to release stream reader lock", error); | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+216
to
+219
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Undefined Same issue as the other two files. The
Suggested change
Was this helpful? React with 👍 or 👎 to provide feedback. |
||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
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.
🔴 Undefined
debugvariable insafeReleaseLockcauses ReferenceError, defeating error safetysafeReleaseLockis a standalone module-level function, not a class method. The new code referencesdebugin the catch block (if (debug)), butdebugis never declared, imported, or passed as a parameter in this file. Ifreader.releaseLock()throws, the catch block will itself throw aReferenceError: debug is not defined, converting a safely-caught error into an uncaught crash — the exact opposite of the function's purpose.Was this helpful? React with 👍 or 👎 to provide feedback.