Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compat with node:net server.listen(port, host, backlog, callback)? #4540

Open
ignoramous opened this issue Sep 7, 2023 · 4 comments
Open
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause node.js Compatibility with Node.js APIs

Comments

@ignoramous
Copy link

ignoramous commented Sep 7, 2023

What version of Bun is running?

0.8.1+16b4bf341acc0f4804f0b6bdf5298c180cd00366

What platform is your computer?

Linux 5.4.0-135-generic x86_64 x86_64

What steps can reproduce the bug?

Listening with server.listen(port, host, backlog, callback) (like we do) does not work when the package is bundled up with bun build --target node. Removing backlog however works.

Also I've noticed that, bun run <entry-point> works as-is (with the backlog arg) but bun build <entry-point> --target node doesn't.

What is the expected behavior?

Do not expect bun bundle <nodejs-entry-point> --target node to behave any differently to bun run <nodejs-entry-point>

What do you see instead?

The Bun process continues executing the rest of the code without reporting any error.

Additional information

Coincidentally, I see the same "bug" (?) with Deno, too.

@ignoramous ignoramous added the bug Something isn't working label Sep 7, 2023
@Electroid Electroid added node.js Compatibility with Node.js APIs needs investigate Needs to be investigated to find the root cause labels Oct 27, 2023
@elmpp
Copy link

elmpp commented Nov 4, 2023

+1

See the following error:

489 |   listen(port, hostname, onListen) {
                   ^
TypeError: The argument 'options' must have the property "port" or "path". Received {"port":"2222","host":"127.0.0.1"}

With the following client code:

)).listen({
    port: process.env.GIT_SSH_MOCK_SERVER_PORT || 2222,
    host: '127.0.0.1',
    debug: console.log,
  }, function () {
    console.log('Listening on port ' + this.address().port)
  })

ETA, may be related to my specifying the port as a string. ParseInt() yields different behaviour

@tteggel
Copy link

tteggel commented Nov 21, 2023

I've hit this in Socket.connect() today. Seems like bad things happen when you pass port as a string e.g. from the env. Node will happily coerce string to number.

@nektro
Copy link
Contributor

nektro commented May 10, 2024

Does this still reproduce for you?

@tteggel
Copy link

tteggel commented May 13, 2024

This works as expected for me now, thanks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs investigate Needs to be investigated to find the root cause node.js Compatibility with Node.js APIs
Projects
None yet
Development

No branches or pull requests

5 participants