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

src: use UV_EINVAL instead of EINVAL in udp_wrap #15444

Closed
wants to merge 5 commits into from

Conversation

danbev
Copy link
Contributor

@danbev danbev commented Sep 17, 2017

Currently if the buffer size exceeds the maximum int size the following
error will be thrown:

dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:

dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

src

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. dgram Issues and PRs related to the dgram subsystem / UDP. labels Sep 17, 2017
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. A test would be nice if possible.

@danbev
Copy link
Contributor Author

danbev commented Sep 17, 2017

LGTM. A test would be nice if possible.

Good point, added a test for this.

type: Error,
message: new RegExp('^Could not get or set buffer' +
' size: Error: EINVAL: invalid argument,' +
' uv_' + type + '_buffer_size$')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I believe a string (instead of a regex) is enough to get exact matching here. You might want to use a template string instead of concatenation, I think we agreed on that preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually used a template for this but the linter complained which is why I changed it. I'll take another look though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use templates, except if the line becomes too long, in that case you can concatenate templates and string literals:

'Could not get or set buffer size: Error: EINVAL: ' +
`invalid argument, uv_${type}_buffer_size`

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated now.

const errorObj = {
code: 'ERR_SOCKET_BUFFER_SIZE',
type: Error,
message: `Could not get or set buffer size: Error: EINVAL: invalid argument, uv_${type}_buffer_size` // eslint-disable-line max-len
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both of the long lines in this file could be handled without disabling the ESLint rule.

@danbev
Copy link
Contributor Author

danbev commented Sep 19, 2017

@jasnell
Copy link
Member

jasnell commented Sep 19, 2017

This failed CI across the board.

@danbev
Copy link
Contributor Author

danbev commented Sep 20, 2017

@jasnell Thanks for the heads up. I see the problem and will take a closer look. (I'm at a f2f this week so response times might not be that good)

Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.
@danbev
Copy link
Contributor Author

danbev commented Sep 20, 2017

@BridgeAR
Copy link
Member

@danbev seems like the CI is green now. Is this ready to land?

@danbev
Copy link
Contributor Author

danbev commented Sep 21, 2017

Looking into this I found won't work without

@danbev seems like the CI is green now. Is this ready to land?

Yep, it is good to go now. I can land it later this evening or tomorrow.

@danbev
Copy link
Contributor Author

danbev commented Sep 21, 2017

@danbev seems like the CI is green now. Is this ready to land?

Yep, it is good to go now. I can land it later this evening or tomorrow.

@BridgeAR
Copy link
Member

@danbev top

danbev added a commit to danbev/node that referenced this pull request Sep 22, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: nodejs#15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@danbev
Copy link
Contributor Author

danbev commented Sep 22, 2017

Landed in f4899ac

@danbev danbev closed this Sep 22, 2017
@danbev danbev deleted the udp_wrap_uv_errors branch September 22, 2017 06:18
addaleax pushed a commit to addaleax/ayo that referenced this pull request Sep 23, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: nodejs/node#15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 28, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: #15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 29, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: #15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 3, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: #15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Oct 3, 2017
MylesBorins pushed a commit that referenced this pull request Oct 3, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: #15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 11, 2017
Currently if the buffer size exceeds the maximum int size the following
error will be thrown:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
Unknown system error 22: Unknown system error 22, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

It looks like perhaps UV_EINVAL was intended to give the following error
message instead:
dgram.js:180
    throw new errors.Error('ERR_SOCKET_BUFFER_SIZE', e);
    ^

Error [ERR_SOCKET_BUFFER_SIZE]: Could not get or set buffer size: Error:
EINVAL: invalid argument, uv_recv_buffer_size
    at bufferSize (dgram.js:180:11)

This commit changes EINVAL to use UV_EINVAL.

PR-URL: #15444
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MylesBorins
Copy link
Contributor

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. dgram Issues and PRs related to the dgram subsystem / UDP.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants