Skip to content

Conversation

@wayfarer3130
Copy link
Collaborator

Fixes a number of crash issues caused by not handling promise rejections correclty and various other issues.

@wayfarer3130 wayfarer3130 requested a review from rleisti January 28, 2026 00:53
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 () => {
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

@wayfarer3130 wayfarer3130 force-pushed the fix/stow-response-fix branch from 63c9fb1 to 29953cc Compare January 30, 2026 17:26
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';
Copy link
Collaborator

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';
Copy link
Collaborator

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();
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants