Unexpected listen result with invalid port #350
-
When using const port = 'bad port';
uws.App()
.listen(
port,
(token) => {
if (token) {
console.log(`Listening on port: ${port}`);
}
else {
console.log(`Failed to start server`);
}
}); The expected result happens However if a host is specified with an invalid port const port = 'bad port';
uws.App()
.listen(
'127.0.0.2',
port,
(token) => {
if (token) {
console.log(`Listening on port: ${port}`);
}
else {
console.log(`Failed to start server`);
}
}); The result is |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
have you tried using a valid port number instead of a random string? the docs say to pass a number and you are passing a random string https://unetworking.github.io/uWebSockets.js/generated/interfaces/templatedapp.html#listen |
Beta Was this translation helpful? Give feedback.
-
@hst-m Absolutely, that works as expected. Although IMO if given an invalid port should satisfy the Upon a slightly closer look it appears that this binding also passes through undocumented options to the lower level uSockets library as well. |
Beta Was this translation helpful? Give feedback.
-
This could be improved with better type checks but it's also possible to follow documented APIs. |
Beta Was this translation helpful? Give feedback.
-
#343 Has the same problematics - types are not checked very strictly |
Beta Was this translation helpful? Give feedback.
have you tried using a valid port number instead of a random string? the docs say to pass a number and you are passing a random string https://unetworking.github.io/uWebSockets.js/generated/interfaces/templatedapp.html#listen