-
Notifications
You must be signed in to change notification settings - Fork 25
Fix/stow response fix #111
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
base: master
Are you sure you want to change the base?
Conversation
…rect-pixel-representation
| import { StreamInfo } from '../lib/instance/StreamInfo.mjs'; | ||
|
|
||
| describe('StreamInfo write and end', () => { | ||
| test('writes Buffer, array of Buffer and TypedArray via write(); returns backpressure; queues when busy', async () => { |
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.
This test only validates negative backpressure (returning true): there isn't a case to validate when write returns false
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.
I'm not quite sure how to validate positive backpressure without really hitting the stream hard, and it is hard to know how hard that has to be to work.
63c9fb1 to
29953cc
Compare
| return Promise.resolve(promise).catch(error => { | ||
| // Error should already be recorded internally by _writeToStream, but catch | ||
| // any unexpected rejections to prevent process termination | ||
| const streamKey = streamInfo?.streamKey || 'unknown'; |
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.
streamKey should be guaranteed to have a value due to the guard above on line 86, unless the streamInfo can be mutated to remove it
| }); | ||
| } catch (syncError) { | ||
| // Handle any synchronous errors (shouldn't happen since _writeToStream is async, but safety net) | ||
| const streamKey = streamInfo?.streamKey || 'unknown'; |
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.
same here: streamKey should be guaranteed to have a value
| }; | ||
|
|
||
| const onSettle = () => { | ||
| check(); |
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.
Could we simplify by moving the content of check into onSettle, or is there a reason they need to be separate functions? I see check returns a boolean while onSettle does not, but that does not look like it would change anything for the callers.
Fixes a number of crash issues caused by not handling promise rejections correclty and various other issues.