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

http2: add support for TypedArray to getUnpackedSettings #36141

Closed

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Nov 16, 2020

This PR is trying to fix the behaviour of http2.getUnpackedSettings.

$ node --version
v16.0.0-pre
$ node -e "http2.getUnpackedSettings('')"
node:internal/http2/core:3167
    throw new ERR_INVALID_ARG_TYPE('buf',
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "buf" argument must be an instance of Buffer, TypedArray, or DataView. Received type string ('')
    at new NodeError (node:internal/errors:258:15)
    at Object.getUnpackedSettings (node:internal/http2/core:3167:11)
    at [eval]:1:7
    at Script.runInThisContext (node:vm:132:18)
    at Object.runInThisContext (node:vm:309:38)
    at node:internal/process/execution:77:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:76:60)
    at node:internal/main/eval_string:23:3 {
  code: 'ERR_INVALID_ARG_TYPE'
}
$ node -e "http2.getUnpackedSettings(new Uint8Array([0,0,0,0,0,0]))"
node:internal/http2/core:3175
    const id = buf.readUInt16BE(offset);
                   ^

TypeError: buf.readUInt16BE is not a function
    at Object.getUnpackedSettings (node:internal/http2/core:3175:20)
    at [eval]:1:7
    at Script.runInThisContext (node:vm:132:18)
    at Object.runInThisContext (node:vm:309:38)
    at node:internal/process/execution:77:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:76:60)
    at node:internal/main/eval_string:23:3

The error message says we can use TypedArray, the documentation says we can use Uint8Array, but in practice only Node.js Buffer object are accepted.

This PR adds support for all TypedArray and remove DataView from the error message. It also updates the documentation.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/http2
  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. http2 Issues or PRs related to the http2 subsystem. labels Nov 16, 2020
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 17, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 17, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 19, 2020
@github-actions github-actions bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 19, 2020
@github-actions
Copy link
Contributor

Landed in 275aa68...ad0a01c

@github-actions github-actions bot closed this Nov 19, 2020
nodejs-github-bot pushed a commit that referenced this pull request Nov 19, 2020
PR-URL: #36141
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@aduh95 aduh95 deleted the http2-getUnpackedSettings-ArrayBufferView branch November 19, 2020 18:12
codebytere pushed a commit that referenced this pull request Nov 22, 2020
PR-URL: #36141
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@codebytere codebytere mentioned this pull request Nov 22, 2020
targos pushed a commit that referenced this pull request May 16, 2021
PR-URL: #36141
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
targos pushed a commit that referenced this pull request Jun 11, 2021
PR-URL: #36141
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. buffer Issues and PRs related to the buffer subsystem. http2 Issues or PRs related to the http2 subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants