exit if the user has requested a specific port#192
exit if the user has requested a specific port#192SvenDowideit wants to merge 2 commits intodat-ecosystem-archive:masterfrom
Conversation
Signed-off-by: Sven Dowideit <sven.dowideit@csiro.au>
b9bdf27 to
4849deb
Compare
Codecov Report
@@ Coverage Diff @@
## master #192 +/- ##
==========================================
- Coverage 84.86% 84.41% -0.46%
==========================================
Files 7 7
Lines 304 308 +4
==========================================
+ Hits 258 260 +2
- Misses 46 48 +2
Continue to review full report at Codecov.
|
| swarm.once('error', function () { | ||
| swarm.once('error', function (err) { | ||
| // Don't magically use any port if the users has requested a specific port | ||
| swarm.emit('errorport', err) |
There was a problem hiding this comment.
Can also we call the callback, cb?
There was a problem hiding this comment.
mmm, looking at that file - no idea, I don't know what it does, or how / when it should be called :/
There was a problem hiding this comment.
ah, ok, that changes the if answer too - awesome, updating.
There was a problem hiding this comment.
mmm, looking at that file - no idea, I don't know what it does, or how / when it should be called :/
The callback can be used to know if there are any network connections (its called back after first round of discovery). But we can pass the error back as the first argument as well.
| swarm.once('error', function (err) { | ||
| // Don't magically use any port if the users has requested a specific port | ||
| swarm.emit('errorport', err) | ||
| swarm.listen(0) |
There was a problem hiding this comment.
Should we call this if opts.port isn't set?
There was a problem hiding this comment.
I originally added an if for that too - but the errorport handling shortcircuits before that, so it seemed cleaner to not add a duplicate if
|
It'd be great to have a test for this. |
Signed-off-by: Sven Dowideit <sven.dowideit@csiro.au>
| swarm.once('error', function () { | ||
| swarm.once('error', function (err) { | ||
| // Don't magically use any port if the users has requested a specific port | ||
| swarm.emit('errorport', err) |
There was a problem hiding this comment.
Can we use emit('error', new Error('specified port not available')) (or similar) for use cases outside the dat cli. Will require less documentation than a custom event =).
(Not sure if I left this before but not seeing it. Apologies if its duplicate.)
|
I updated the CLI PR for this to avoid a custom error message. It'd still be good to have this in dat-node but will leave it to user for now. |
Signed-off-by: Sven Dowideit sven.dowideit@csiro.au
for dat-ecosystem/dat#945