FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: remove unnecessary .toString() calls in HTTP tests by addaleax · Pull Request #43731 · nodejs/node · GitHub

/ node Public

test: remove unnecessary .toString() calls in HTTP tests - #43731

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
addaleax:remove-unnecessary-tostring-in-http-tests
Jul 11, 2022
Merged

test: remove unnecessary .toString() calls in HTTP tests#43731
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
addaleax:remove-unnecessary-tostring-in-http-tests

Conversation

addaleax commented Jul 8, 2022

Copy link
Copy Markdown
Member

Let’s not have bad examples in our test suite and instead use the
proper way of converting stream data to UTF-8
(i.e. stream.setEncoding('utf8')) in all places.

Let’s not have bad examples in our test suite and instead use the
proper way of converting stream data to UTF-8
(i.e. `stream.setEncoding('utf8')`) in all places.
addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 8, 2022
nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jul 8, 2022
addaleax added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. and removed needs-ci PRs that need a full CI run. labels Jul 8, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 8, 2022

Copy link
Copy Markdown
Collaborator

response += chunk;
}));

client.setEncoding('utf8');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Nit(feel free to ignore): would be better to move client.setEncoding('utf8'); before client.on('data'?

Reason:

  1. keep consistent with other use cases
  2. don't make us guess if client.setEncoding('utf8') after attach data listener would cause problem.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Fwiw, my preferred way is client.setEncoding('utf8').on('data', ...') 😄

Ultimately, it doesn't matter. If we do clean this up, it might also be a good idea to do so across all tests for consistency.

wa-Nadoo commented Jul 8, 2022
edited
Loading

Copy link
Copy Markdown

Maybe it is time to doc-deprecate buffer.toString() params at all?

addaleax commented Jul 8, 2022

Copy link
Copy Markdown
Member Author

Maybe it is time to doc-deprecate buffer.toString() params at all?

I don't think that that's practical or meaningful. We should just push really hard to avoid examples like these so that people know not to do it this way 🙂 Also, this is something that TypeScript would have caught at least in the cases where .setEncoding() is already being used.

aduh95 added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jul 8, 2022

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 11, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jul 11, 2022
nodejs-github-bot merged commit febb539 into nodejs:main Jul 11, 2022

Copy link
Copy Markdown
Collaborator

Landed in febb539

targos pushed a commit that referenced this pull request Jul 12, 2022
Let’s not have bad examples in our test suite and instead use the
proper way of converting stream data to UTF-8
(i.e. `stream.setEncoding('utf8')`) in all places.

PR-URL: #43731
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 outstanding review comments, and a CI started. http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL