-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
dgram: instantiate socket on creation #5496
Copy link
Copy link
Closed
Labels
dgramIssues and PRs related to the dgram subsystem / UDP.Issues and PRs related to the dgram subsystem / UDP.libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.semver-majorPRs that contain breaking changes and should be released in the next major version.PRs that contain breaking changes and should be released in the next major version.
Metadata
Metadata
Assignees
Labels
dgramIssues and PRs related to the dgram subsystem / UDP.Issues and PRs related to the dgram subsystem / UDP.libuvIssues and PRs related to the libuv dependency or the uv binding.Issues and PRs related to the libuv dependency or the uv binding.semver-majorPRs that contain breaking changes and should be released in the next major version.PRs that contain breaking changes and should be released in the next major version.
In Node 5.7.0 and all currently-supported previous versions, it is possible to try to trigger an exception (
EBADF) with code such as this:As @saghul explains in #5023, this is because
dgraminstantiates the socket lazily withuv_udp_init(). Ifuv_udp_init_ex()were used instead, then the socket could be created and ready for the various.set*functions upon creation.Such a change would probably be
semver-majorbecausecreateSocket()might throw whereas currently that is not the case.There are probably loads of other dangers and considerations. (I'm opening this issue so that the discussion can be had independently of the PR linked above, which is a relatively minor and safe change to a test file. This, on the other hand, would be a much bigger deal...)