Skip to content

Conversation

@dicej
Copy link
Contributor

@dicej dicej commented Nov 4, 2025

This fixes and adds test coverage for a couple of bugs involving component model streams:

delay returning Dropped until producer buffer drained

If the StreamProducer calls Destination::set_buffer, we need to make sure all the items in that buffer have been delivered to the receiver (or the receiver closes its end) before telling it the write end has been dropped.

reset read/write state back to Open on event delivery

If one end of a stream does a partial read or write, we leave the other end in a GuestReady state, allowing further reads or writes to proceed until the buffer has been drained or filled, respectively. However, once we've delivered the event regarding the partial operation, we need to set the state back to Open, since we'll have released the buffer back to the guest at that point.

dicej added 3 commits November 4, 2025 14:43
If one end of a stream does a partial read or write, we leave the other end in a
`GuestReady` state, allowing further reads or writes to proceed until the buffer
has been drained or filled, respectively.  However, once we've delivered the
event regarding the partial operation, we need to set the state back to `Open`,
since we'll have released the buffer back to the guest at that point.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
If the `StreamProducer` calls `Destination::set_buffer`, we need to make sure
all the items in that buffer have been delivered to the receiver (or the
receiver closes its end) before telling it the write end has been dropped.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
These cover a couple of scenarios where the guest and/or host read owned
resource items one-at-a-time from writes of more than one item, forcing the
writer to re-take ownership of the unwritten items between writes.

This also covers the case where the host's `StreamProducer` returns
`StreamResult::Dropped` after calling `Destination::set_buffer`, in which case
Wasmtime must delay telling the other end about the dropped stream until that
buffer has been drained.

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
@dicej dicej requested a review from a team as a code owner November 4, 2025 21:48
@dicej dicej requested review from alexcrichton and fitzgen and removed request for a team and fitzgen November 4, 2025 21:48
@dicej dicej added this pull request to the merge queue Nov 4, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 4, 2025
@dicej dicej added this pull request to the merge queue Nov 4, 2025
Merged via the queue into bytecodealliance:main with commit efd56f6 Nov 4, 2025
45 checks passed
@dicej dicej deleted the partial-read-write-fixes branch November 4, 2025 23:52
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.

2 participants