-
Notifications
You must be signed in to change notification settings - Fork 17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small thing. Otherwise looks good
async function spawnGoLibp2p() { | ||
if (!existsSync('../../examples/go-libp2p-server/go-libp2p-server')) { | ||
await new Promise((resolve, reject) => { | ||
exec('go build', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, might as well just always run it, no? instead of building it first?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! this should be documented. go run ./main.go
builds the program then starts a subprocess for the program. SIGINT on the parent process doesn't stop the subprocess (try running go run
in the background and issuing a kill -2 pid
). By running the binary directly we avoid the indirection and SIGINT works as expected.
I wonder if we could SIGKILL this instead and it would work?
I don't think it's worth changing in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it is probably out of scope. More of a note.
@@ -5,14 +5,20 @@ | |||
"type": "module", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it falls out of scope for this PR, but something to think about is that we might as well turn this repo into a workspace. This way the example and webrtc package could be both living in the same package, allowing the example to make use of the @libp2p/webrtc package the same as any external usage would. Making the example also directly copyable without having to rely on relative paths in its package.json to make it work given that the relative paths would be fixed by the root workspace definition :) Just my 2 cents on this matters, but feels cleaner to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pathing has been removed in favor of the npm package import. The example was written before the package was released, so this was something that needed to be done now that it's published. Thanks for the reminder!
Regarding the placement of this comment, is there a concern with "type": "module"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No no, just decided to put it on top of the file it was related to. Sorry for the confusion there.
|
||
play.describe('bundle ipfs with parceljs:', () => { | ||
// DOM | ||
const connectBtn = '#connect' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 comments:
- is there no convention for constants, in many language it's something like
UPPER_CASE
but dunno about ts or PL in general. Either way I would expect it to be different from regular variable names? - might want to use a convention suffix for these ones to make clear that these are Html Element Identifier strings rather than actual "buttons", "addresses", "input fields", etc...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convention suffix for these ones to make clear that these are Html Element Identifier strings rather than actual "buttons"
That's what the types are for :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What types? O.O
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean that this could be implied because it is of type str? Dunno, not entirely sure that is the case. Certainly not for the output one imho. I like to be very clear about this thing, but neither do I want to make a foothold here, so I'm fine with whatever you end up choosing here, just note from my POV.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my mistake, I thought this was a .ts
file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a borrow from the WebTransport Playwright test, though Hungarian(ish) notation may be beneficial here. I'm OK leaving as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notation botters me only minor, so not too worried about that. But when I read the usage for a variable "connectBtn" I do not really link it to something being a (string) ID to an HTML element. That's my main concern here. But not a strong opinion given the minor size of the file, so feel free to take it as you wish.
play.beforeAll(async ({ }, testInfo) => { | ||
testInfo.setTimeout(5 * 60_000) | ||
const s = await spawnGoLibp2p() | ||
server = s.server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dunno what the convention is but unpacking { server, serverAddress} = s
should work here, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is assigning to closured variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm, ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these are singletons where the variables are scoped in the play.describe
closure. The styleguide for this repo doesn't use semicolons, so doing the recommended destructuging assignment on an already defined variable causes issues:
({ server, serverAddr } = await spawnGoLibp2p())
The parser appends this to the setTimeout()
function call above it (even with an extra line break), resulting in a TypeError: TypeError: testInfo.setTimeout(...) is not a function
.
Adding semicolons resolves the issue but makes the code incompatible with the main js-libp2p
styles and one that Aegir expects in lints.
I'm going to leave as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More then fair enough. Sorry for the trouble 😰
}) | ||
|
||
play.beforeEach(async ({ servers, page }) => { | ||
console.log(`http://localhost:${servers[0].port}/`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I log and use such a composed value I usually assign it to a const first, but no biggie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this suggestion ❤️ It's implemented.
"it-pushable": "^3.1.0", | ||
"js-libp2p-webrtc": "../../", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"js-libp2p-webrtc": "../../", | |
"@libp2p/webrtc": "../../", |
Addresses issue #86