Skip to content

Conversation

@anonrig
Copy link
Member

@anonrig anonrig commented Jan 23, 2026

Tests certain edge cases which are not covered in standard.c++

@anonrig anonrig requested a review from jasnell January 23, 2026 19:59
@anonrig anonrig requested review from a team as code owners January 23, 2026 19:59
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.67%. Comparing base (a5c6178) to head (7dba154).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5950   +/-   ##
=======================================
  Coverage   69.67%   69.67%           
=======================================
  Files         397      397           
  Lines      105999   105999           
  Branches    17965    17965           
=======================================
  Hits        73853    73853           
- Misses      21351    21354    +3     
+ Partials    10795    10792    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 23, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 11.48%

Comparing yagiz/add-streams-standard (7dba154) with main (752ea91)

Summary

❌ 1 regressed benchmark
✅ 69 untouched benchmarks
⏩ 129 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
simpleStringBody[Response] 19.1 µs 21.6 µs -11.48%

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

// First read gets the data
const result1 = await reader.read();
strictEqual(result1.value, 'data');
strictEqual(result1.done, false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be documented that this is actually incorrect behavior that we should likely fix. The expectation in this case (as evidenced in other runtimes) is that the first read should reject with an error. The read should NOT actually be fulfilled.

// Cancel should handle pending state
await rs.cancel('cancel reason');

// The read should complete (with done=true due to close)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per the spec, the read should be canceled when the lock is released. This is another deviation from the spec we should fix.


strictEqual(result.done, true);
ok(result.value instanceof Uint8Array);
strictEqual(result.value.byteLength, 0);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely also verify that it's the same backing store as the input.

Comment on lines +536 to +540
write() {
return new Promise((resolve) => {
resolveWrite = resolve;
});
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
write() {
return new Promise((resolve) => {
resolveWrite = resolve;
});
},
write() {
const { promise, resolve } = Promise.withResolvers();
resolveWrite = resolve;
return promise;
},

resolveWrite();
await writePromise;
resolveWrite();
await writePromise2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check that desiredSize returns back to 1

controller = c;
},
pull(c) {
// Respond with less data than requested to keep BYOB request alive
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the "keep BYOB request alive" part here mean? Calling respond(1) fulfills the request. There's nothing "kept alive"

};

// Test consumerCount edge case (lines 954-967)
// This is triggered when checking consumer count during certain operations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you describe the "certain operations" more here. It's not clear exactly what edge case this is testing.

});

// Cancel should resolve immediately for closed stream
await rs.cancel();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear what exactly this is testing. There are no assertions and there's no indication of what the failure case would be.

c.enqueue(new TextEncoder().encode('hello'));
c.enqueue(new Uint8Array(0)); // Empty chunk - should be skipped
c.enqueue(new TextEncoder().encode(' world'));
c.close();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's really no way of verifying in this test that the empty chunk was actually skipped.

async test() {
// Create a stream that returns a non-byte value
// This is tricky because workerd streams are typically byte-oriented
// We need to use internal APIs or specific conditions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment does not make sense. You're returning byte data. You're not creating "a stream that returns a non-byte value"

const reader = rs.getReader({ mode: 'byob' });

const r1 = await reader.read(new Uint8Array(5));
strictEqual(r1.value[0], 1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be checking the lengths of value[0] also

let pullCount = 0;
const rs = new ReadableStream({
type: 'bytes',
// No autoAllocateChunkSize - pull must use enqueue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our implementation, by default, always sets autoAllocateChunkSize. There's a new compat flag to enable more standard behavior. Specifically, without that compat flag this comment is incorrect.

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