Skip to content

Commit

Permalink
Merge pull request #20 from th-ch/fix-close
Browse files Browse the repository at this point in the history
Fix close method for stream
  • Loading branch information
th-ch authored Jan 3, 2025
2 parents 157dcb8 + 6160996 commit c1a83e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import {Config, defaultConfig} from './mux';
import {Stream} from './stream';

export class Session extends Transform {
// localGoAway indicates that we should stop accepting futher connections
// localGoAway indicates that we should stop accepting further connections
private localGoaway = false;

// remoteGoAway indicates the remote side does not want futher connections.
// remoteGoAway indicates the remote side does not want further connections.
private remoteGoAway = false;

// nextStreamID is the next stream we should send. This depends if we are a client/server.
Expand Down
2 changes: 2 additions & 0 deletions src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ export class Stream extends Duplex {
case STREAM_STATES.Established:
this.state = STREAM_STATES.LocalClose;
this.sendClose();
break;

case STREAM_STATES.LocalClose:
case STREAM_STATES.RemoteClose:
this.state = STREAM_STATES.LocalClose;
this.sendClose();
this.session.closeStream(this.id);
break;
}
}

Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1443,11 +1443,11 @@ __metadata:

"typescript@patch:typescript@npm%3A^5.7.2#optional!builtin<compat/typescript>":
version: 5.7.2
resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin<compat/typescript>::version=5.7.2&hash=5786d5"
resolution: "typescript@patch:typescript@npm%3A5.7.2#optional!builtin<compat/typescript>::version=5.7.2&hash=8c6c40"
bin:
tsc: bin/tsc
tsserver: bin/tsserver
checksum: 10c0/f3b8082c9d1d1629a215245c9087df56cb784f9fb6f27b5d55577a20e68afe2a889c040aacff6d27e35be165ecf9dca66e694c42eb9a50b3b2c451b36b5675cb
checksum: 10c0/c891ccf04008bc1305ba34053db951f8a4584b4a1bf2f68fd972c4a354df3dc5e62c8bfed4f6ac2d12e5b3b1c49af312c83a651048f818cd5b4949d17baacd79
languageName: node
linkType: hard

Expand Down

0 comments on commit c1a83e8

Please sign in to comment.