Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Review comments #84

Merged
merged 5 commits into from
Jan 23, 2023
Merged

Review comments #84

merged 5 commits into from
Jan 23, 2023

Conversation

MarcoPolo
Copy link
Contributor

@MarcoPolo MarcoPolo commented Jan 20, 2023

Overall this looks good. I added some changes and left a couple of questions in the code. Once those questions are addressed and my changes make sense, I can update the code and merge these changes.

I ran eslint on the files I touched. It may be better to review with the ?w=1 option to ignore whitespace changes.

src/stream.ts Outdated
this.channel.send(sendbuf.subarray())
}

// Close the channel after the source has ended
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This tripped me up as well. See libp2p/js-libp2p-webtransport#23

Copy link
Collaborator

Choose a reason for hiding this comment

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

The referenced PR and the current implementation would both break on cases similar to:

const response = await pipe([request], stream, sink)
// process response
await pipe([request1], stream)

However, it might be better to use it-pushable or it-handshake in these cases.
I've refactored the sink to be more readable, and also limited sink to being called once similar to the referenced PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The referenced PR and the current implementation would both break on cases similar to...

Yes. That's intentional in the js-libp2p design. And the workaround is using a pushable like you mentioned. I'm not a fan of this, but this is how everything else is setup, so it would be even more confusing if this deviated from it.

src/muxer.ts Outdated Show resolved Hide resolved

// no default
default:
unreachableBranch(flag)
Copy link
Collaborator

Choose a reason for hiding this comment

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

💯

}

if (currentState === StreamStates.OPEN || currentState === StreamStates.WRITE_CLOSED) {
this._sendFlag(pb.Message_Flag.STOP_SENDING)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting, I wonder how that semicolon got past the linter 🤔

@ddimaria
Copy link
Collaborator

Thanks for the PR @MarcoPolo! The refactors make the code more readable 💯. @ckousik will respond to 2 of the TODOs on Monday.

@ckousik
Copy link
Collaborator

ckousik commented Jan 23, 2023

@MarcoPolo I've addressed the changes in https://github.com/libp2p/js-libp2p-webrtc/tree/ckousik/review . Can I push to the branch on this PR instead?

@MarcoPolo
Copy link
Contributor Author

MarcoPolo commented Jan 23, 2023

@ckousik please do. Edit, I already did it.

*/
reset (): void {
// TODO Why are you resetting the stat here?
this.stat = defaultStat(this.stat.direction)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should remove this. Am I missing something?

@MarcoPolo
Copy link
Contributor Author

Merging this as my repo review comments. @achingbrain this repo is ready for your review whenever you're ready.

@MarcoPolo MarcoPolo merged commit 08687c3 into main Jan 23, 2023
@MarcoPolo MarcoPolo deleted the marco/review branch January 23, 2023 20:46
@p-shahi p-shahi mentioned this pull request Jan 23, 2023
2 tasks
@github-actions
Copy link

🎉 This PR is included in version 1.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants