Skip to content

crypto: runtime deprecate DEFAULT_ENCODING - #18333

Closed
jasnell wants to merge 1 commit into
nodejs:masterfrom
jasnell:refactor-default-encoding
Closed

crypto: runtime deprecate DEFAULT_ENCODING#18333
jasnell wants to merge 1 commit into
nodejs:masterfrom
jasnell:refactor-default-encoding

Conversation

@jasnell

@jasnelljasnell commented Jan 24, 2018

Copy link
Copy Markdown
Member

Docs-only Runtime deprecate the crypto.DEFAULT_ENCODING and replace by directly exposing the getDefaultEncoding/setDefaultEncoding functions that are used as it's getter and setter.

This is specifically in preparation for eventual ESM support

Refs: #18131

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
Affected core subsystem(s)

crypto

@jasnelljasnell added crypto Issues and PRs related to the crypto subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. labels Jan 24, 2018
@nodejs-github-botnodejs-github-bot added the crypto Issues and PRs related to the crypto subsystem. label Jan 24, 2018
@jasnell
jasnell requested a review from a teamJanuary 24, 2018 00:03
@addaleax

Copy link
Copy Markdown
Member

I am reluctant to introduce new APIs for a legacy feature; this is really just here to support old applications (pre-2012!).

Like, I’m totally 👍 on the deprecation. But if you want to retrieve a string in a specific encoding, you should pass that option explicitly when calling then function anyway.

@jasnell

Copy link
Copy Markdown
MemberAuthor

So I know, is that -1 reluctant or -0 reluctant?

@addaleax

Copy link
Copy Markdown
Member

@jasnell That is -1 unless there’s a good reason that I don’t see, which is totally possible.

@jasnell

Copy link
Copy Markdown
MemberAuthor

Ok. Fwiw, these methods already exist as the getter/setter. The only additional cost is the overhead of introducing new public API. Let's see how others feel about it, ok?

Comment threaddoc/api/deprecations.md Outdated

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.

#crypto_crypto_defaultencoding -> #crypto_crypto_default_encoding?

@ChALkeRChALkeRJan 25, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@jasnell This wasn't fixed in the «nits»-fix commit ;-)

https://nodejs.org/api/crypto.html#crypto_crypto_default_encoding is the actual link, so it indeed should be crypto.html#crypto_crypto_default_encoding .

Comment threaddoc/api/deprecations.md Outdated

@TrottTrottJan 24, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we keep this wording consistent with other messages by changing it to this?:

The [`crypto.DEFAULT_ENCODING`][] property is deprecated. Please use
`crypto.getDefaultEncoding()` and `crypto.setDefaultEncoding()` instead.

@jasnelljasnell added this to the 10.0.0 milestone Jan 24, 2018

@addaleaxaddaleax left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just marking this with the red X so my objection doesn’t get lost

@mcollina

Copy link
Copy Markdown
Member

I would prefer we deprecate this and remove it in 11. Unless this feature is needed by some very popular module, in which case we might have to do what you propose.

@devsnek

Copy link
Copy Markdown
Member

fwiw if its needed by some very popular module we can just ping the author and ask them to refactor the calls

@jasnell

Copy link
Copy Markdown
MemberAuthor

Ok, so that brings up the next question: instead of docs-deprecation-with-replacement, should we just go with a full runtime deprecation of the property and not worry about replacing it?

ChALkeR
ChALkeR previously requested changes Jan 24, 2018

@ChALkeRChALkeR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This property was added 5 years ago as a temporary measure, documented for future deprecation in 2015 (in 6.0 release). I'm pretty sure we don't want to introduce a new API around it, unless there is some valid usecase that we would want to support and are missing.

+1 to doc or runtime deprecation.

@ChALkeR

Copy link
Copy Markdown
Member

The usage seems to be really low, I'm for runtime-deprecation.

@jasnell
jasnellforce-pushed the refactor-default-encoding branch from 1dd37a1 to dbb4e9bCompareJanuary 24, 2018 18:35
@jasnelljasnell changed the title crypto: docs-only deprecate DEFAULT_ENCODING, replacecrypto: runtime deprecate DEFAULT_ENCODINGJan 24, 2018
@jasnell
jasnellforce-pushed the refactor-default-encoding branch from dbb4e9b to 144ab92CompareJanuary 24, 2018 18:40
@jasnell

Copy link
Copy Markdown
MemberAuthor

Updated to use a runtime deprecation with no new API exposed.

Comment threaddoc/api/crypto.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

avoided

Comment threaddoc/api/crypto.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Comment threadlib/crypto.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove this line?

Comment threadlib/internal/crypto/util.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this change does not seem to be directly related to the deprecation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should probably go into a separate PR if still wanted.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Ah, right, yeah. missed this.

@ChALkeRChALkeR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM with already mentioned nits and undoing (or explaining) changes in util.js.

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@jasnell

Copy link
Copy Markdown
MemberAuthor

@jasnell
jasnellforce-pushed the refactor-default-encoding branch from 4736855 to 909643aCompareJanuary 26, 2018 20:12
@jasnell

Copy link
Copy Markdown
MemberAuthor

https://ci.nodejs.org/job/node-test-pull-request/12762/

@jasnell

Copy link
Copy Markdown
MemberAuthor

CI looks good, although there is an issue with the arm build bots

Runtime deprecate the crypto.DEFAULT_ENCODING property.
This is specifically in preparation for eventual ESM support
Refs: nodejs#18131
@jasnell
jasnellforce-pushed the refactor-default-encoding branch from 4bf301f to 79a4683CompareJanuary 31, 2018 23:35
@jasnell

Copy link
Copy Markdown
MemberAuthor

New CI, just to be safe: https://ci.nodejs.org/job/node-test-pull-request/12863/

@jasnell

Copy link
Copy Markdown
MemberAuthor

Build bot failures on multiple CI bots but otherwise ok.

jasnell added a commit that referenced this pull request Feb 1, 2018
Runtime deprecate the crypto.DEFAULT_ENCODING property.
This is specifically in preparation for eventual ESM support
Refs: #18131
PR-URL: #18333
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
@jasnell

Copy link
Copy Markdown
MemberAuthor

landed in 6035bee

@jasnelljasnell closed this Feb 1, 2018
@jasnelljasnell mentioned this pull request Feb 1, 2018
4 tasks
jasnell added a commit to jasnell/node that referenced this pull request Feb 1, 2018
MayaLekova pushed a commit to MayaLekova/node that referenced this pull request May 8, 2018
Runtime deprecate the crypto.DEFAULT_ENCODING property.
This is specifically in preparation for eventual ESM support
Refs: nodejs#18131
PR-URL: nodejs#18333
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
tniessen added a commit to tniessen/node that referenced this pull request Mar 21, 2023
Citing 76b0bdf from 2012, "only use
this as a temporary measure."
Getting or setting DEFAULT_ENCODING has emitted a warning ever since
Node.js 10, so it seems appropriate to remove it in Node.js 20 five
years later. The last Node.js version that did not emit a warning
reached its end-of-life status at the end of 2019.
This commit only removes the public API so that the change can land in
time for Node.js 20.
Refs: nodejs/node-v0.x-archive#4179
Refs: nodejs#18333
nodejs-github-bot pushed a commit that referenced this pull request Mar 26, 2023
Citing 76b0bdf from 2012, "only use
this as a temporary measure."
Getting or setting DEFAULT_ENCODING has emitted a warning ever since
Node.js 10, so it seems appropriate to remove it in Node.js 20 five
years later. The last Node.js version that did not emit a warning
reached its end-of-life status at the end of 2019.
This commit only removes the public API so that the change can land in
time for Node.js 20.
Refs: nodejs/node-v0.x-archive#4179
Refs: #18333
PR-URL: #47182
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Beth Griggs <bethanyngriggs@gmail.com>
Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cryptoIssues and PRs related to the crypto subsystem.semver-majorPRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

11 participants

@jasnell@addaleax@mcollina@devsnek@ChALkeR@Trott@targos@tniessen@JungMinu@vsemozhetbyt@nodejs-github-bot