Skip to content

server.close() callback error argument is undefined #47261

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

Open
armanbilge opened this issue Mar 26, 2023 · 3 comments
Open

server.close() callback error argument is undefined #47261

armanbilge opened this issue Mar 26, 2023 · 3 comments

Comments

@armanbilge
Copy link

Version

v19.8.1

Platform

Linux armanbilge-sandbox-d5bpibghud0 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

const net = require("net")
const server = net.createServer()
server.listen()
server.close(x => console.log(typeof(x)))

How often does it reproduce? Is there a required condition?

No response

What is the expected behavior? Why is that the expected behavior?

Following discussion in #44290 (comment) and #47229 (comment), to be consistent with other Node.js APIs null should be used to indicate there is no error.

What do you see instead?

$ npx node@19 test.js 
undefined

Additional information

No response

@mk-pmb
Copy link

mk-pmb commented Mar 26, 2023

I don't see a bug here. Robustness principle at work. (More details in #47229 )

@jswalden
Copy link

jswalden commented May 1, 2025

I kicked off the process of getting the TypeScript bindings changed to use err?: Error | null rather than err?: Error to align with reality here. DefinitelyTyped/DefinitelyTyped#72657

@jswalden
Copy link

jswalden commented May 6, 2025

Oh, I misread, this isn't supplying null here, never mind. Binding types ain't gonna change until that change, I'd fully expect.

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

No branches or pull requests

3 participants