Skip to content

Commit

Permalink
feat(stream): immediately exit send loop when scope is disposed
Browse files Browse the repository at this point in the history
  • Loading branch information
justmoon committed Oct 26, 2024
1 parent b7aaabb commit c1e4d79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/chilly-jars-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@dassie/lib-protocol-stream": patch
---

Immediately stop sending when scope is disposed
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function sendUntilDone(state: ConnectionState) {

state.sendLoopPromise = (async function sendLoop() {
for (;;) {
const hasWork = hasWorkToDo(state)
const hasWork = !state.scope.isDisposed && hasWorkToDo(state)

// If we have no more new work to do and no work is in progress, that
// means we are fully done and can end the loop.
Expand Down

0 comments on commit c1e4d79

Please sign in to comment.