| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Review requested:
|
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #63162 +/- ##
=========================================
Coverage 90.04% 90.05%
=========================================
Files 713 714 +1
Lines 224484 225597 +1113
Branches 42430 42663 +233
=========================================
+ Hits 202134 203154 +1020
- Misses 14156 14239 +83
- Partials 8194 8204 +10
... and 78 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
|
The slim tarball CI checks are failing with an unexpected DEP0206 warning in test-crypto-hmac.js. could someone help me understand how to fix this? |
Sorry, something went wrong.
There was a problem hiding this comment.
Root cause: common.expectWarning keys handlers by warning name, so the inline expectWarning at the bottom of test-crypto-hmac.js (added by #52071 for DEP0181) overwrites the new top-of-file registration this PR adds.
By the time both warnings emit asynchronously on process.nextTick, only the DEP0181 handler is active, DEP0206 then hits an empty expected list and triggers Unexpected extra warning received in CI.
The suggestions move both expectations into the top expectWarning and drop the duplicate block. Line 18 already covers DEP0181.
Verified on a fork I pushed both changes to my fork and ran the full GitHub Actions matrix at https://github.com/soulee-dev/node/pull/1:`parallel/test-crypto-hmac`, parallel/test-crypto-dep0206, and all the previously-failing workflows (test-linux, test-macOS, test-tarball, shared-libraries) pass green.
If you commit the first suggestion via GitHub's "Commit suggestion" button,
GitHub will automatically add me as Co-Authored-By on that commit. For the block-deletion comment, would you mind adding Co-Authored-By: Soul Lee <alus20x@gmail.com> manually when you amend? Thanks!
Sorry, something went wrong.
| common.expectWarning({ | ||
| DeprecationWarning: { | ||
| DEP0206: 'Calling digest() on an already-finalized Hmac instance is deprecated.', | ||
| }, | ||
| }); |
There was a problem hiding this comment.
| common.expectWarning({ | |
| DeprecationWarning: { | |
| DEP0206: 'Calling digest() on an already-finalized Hmac instance is deprecated.', | |
| }, | |
| }); | |
| common.expectWarning({ | |
| DeprecationWarning: { | |
| DEP0181: 'crypto.Hmac constructor is deprecated.', | |
| DEP0206: 'Calling digest() on an already-finalized Hmac instance is | |
| deprecated.', | |
| }, | |
| }); |
The existing inline expectWarning block at the bottom of this file (lines
471–478) registers a separate handler for DeprecationWarning, which
overwrites this one because expectWarning is keyed by warning name. Adding
DEP0181 here lets us drop the bottom block — see the review summary for the
full rationale and the additional deletion.
Sorry, something went wrong.
There was a problem hiding this comment.
Please also delete this block:
-{
- crypto.Hmac('sha256', 'Node');
- common.expectWarning({
- DeprecationWarning: [
- ['crypto.Hmac constructor is deprecated.',
- 'DEP0181'],
- ]
- });
-}DEP0181 now registered at the top of the file (suggestion above),
this inline registration is the source of the conflict. Line 18's
crypto.Hmac('sha256', 'Node') already exercises the
constructor-without-new path, so removing this block doesn't lose coverage.
Sorry, something went wrong.
There was a problem hiding this comment.
thanks for the detailed root cause analysis and for verifying on your fork! Will make both changes shortly and add you as co-author.
Sorry, something went wrong.
There was a problem hiding this comment.
LGMT !
Sorry, something went wrong.
| throwing an error. This behavior is inconsistent with `hash.digest()` and | ||
| may lead to subtle bugs. Calling `hmac.digest()` on a finalized `Hmac` instance | ||
| will throw an error in a future version. | ||
|
|
There was a problem hiding this comment.
To help user that face this deprecation, we should have an code example of what happened
const crypto = require('crypto');
const hmac = crypto.createHmac('sha256', 'secret');
hmac.update('hello');
console.log(hmac.digest('hex')); // works
console.log(hmac.digest('hex')); // ❌ currently returns empty string/buffer
Sorry, something went wrong.
There was a problem hiding this comment.
thanks for the suggestion! I'll add the code example to the deprecations doc shortly.
Sorry, something went wrong.
Signed-off-by: anshikakalpana <anshikajain196872@gmail.com> Co-Authored-By: Soul Lee <alus20x@gmail.com>
|
Hi @ChALkeR ! quick ping on #63162 . The docs deprecation from #63121 is already in, and this PR adds the runtime warning (DEP0206) to finish the cycle. Would love a review when you get a chance! |
Sorry, something went wrong.
|
Resolved the merge conflicts and updated the branch. CI should be up to date now. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Refs: #62838
Refs: #63121
Situation
Calling digest() on an already-finalized Hmac instance currently returns an empty buffer silently instead of throwing an error. This is inconsistent with Hash behavior which throws ERR_CRYPTO_HASH_FINALIZED and is a potential security footgun.
Change
Add a runtime deprecation warning (DEP0206) when digest() is called more than once on an Hmac instance. The existing behavior (returning an empty buffer) is preserved during the deprecation cycle to avoid breaking changes. docs-only deprecation was introduced in #63121.