Skip to content

src: revert V8 entropy source optimization - #66903

Closed
panva wants to merge 2 commits into
nodejs:mainfrom
panva:revert-v8-entropy
Closed

panva wants to merge 2 commits into
nodejs:mainfrom
panva:revert-v8-entropy

Conversation

@panva

@panva panva commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

This reverts commits 43d3fe9 and 6ecfd65.

I keep finding fallout from this change. It already needed special handling for AIX and OpenSSL provider initialization, and changed behavior with unavailable DRBGs and --secure-heap. Since landing, I've had to mark test-worker-init-failure flaky on SmartOS because of descriptor-dependent entropy failures. Now I'm seeing intermittent test-crypto-x509 failures across GHA and Jenkins.

The X509 failures come from removing eager OpenSSL initialization: background CA loading can race with key decoding while OpenSSL is still populating its algorithm names. Reverting restores initialization before that concurrency starts.

The startup improvement isn't in my opinion worth continuing to chase these failures.

@panva panva added flaky-test Issues and PRs involving tests that fail intermittently in CI. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. labels Oct 21, 2026
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Oct 21, 2026
@panva panva added the revert PRs that revert previously landed PRs. label Oct 21, 2026
@panva

panva commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

This locally reproduces the X509 failure that flakes in CI. Eight workers decode an RSA-PSS certificate concurrently with background CA loading. On main I get ERR_OSSL_EVP_DECODE_ERROR while with the revert it passes.

Source
// Flags: --expose-internals
'use strict';

const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

const { hasOpenSSL, isBoringSSL } = require('../common/crypto');
if (isBoringSSL || !hasOpenSSL(3))
  common.skip('OpenSSL 3 providers are required');

const { getOptionValue } = require('internal/options');
if (getOptionValue('[ssl_openssl_cert_store]'))
  common.skip('off-thread CA loading is disabled');

const assert = require('node:assert');
const { spawnSync } = require('node:child_process');
const { X509Certificate } = require('node:crypto');
const { once } = require('node:events');
const {
  Worker,
  parentPort,
  workerData,
} = require('node:worker_threads');
const fixtures = require('../common/fixtures');

if (workerData?.barrier) {
  parentPort.postMessage('ready');
  Atomics.wait(workerData.barrier, 0, 0);
  const cert = new X509Certificate(workerData.pem);
  assert.strictEqual(cert.publicKey.asymmetricKeyType, 'rsa-pss');
  assert(Buffer.isBuffer(cert.toLegacyObject().pubkey));
} else if (process.argv[2] !== 'child') {
  // Each process needs cold OpenSSL state. Repeat the concurrent first use to
  // exercise different schedules of certificate loading and key decoding.
  for (let i = 0; i < 3; i++) {
    const child = spawnSync(process.execPath, [
      ...process.execArgv,
      __filename,
      'child',
    ], { encoding: 'utf8' });
    assert.strictEqual(child.signal, null, child.stderr || child.stdout);
    assert.strictEqual(child.status, 0, child.stderr || child.stdout);
  }
} else {
  const { internalBinding } = require('internal/test/binding');
  const binding = internalBinding('crypto');
  const pem = fixtures.readKey('rsa_pss_cert_2048.pem');
  const barrier = new Int32Array(new SharedArrayBuffer(4));

  async function run() {
    const ready = [];
    const exited = [];
    // Load the workers before starting CA loading so their first key decodes
    // can overlap with the background thread's first certificate decodes.
    for (let i = 0; i < 8; i++) {
      const worker = new Worker(__filename, {
        workerData: { pem, barrier },
      });
      ready.push(once(worker, 'message').then(([message]) => {
        assert.strictEqual(message, 'ready');
      }));
      exited.push(once(worker, 'exit').then(common.mustCall(([code]) => {
        assert.strictEqual(code, 0);
      })));
    }
    await Promise.all(ready);
    binding.startLoadingCertificatesOffThread();
    Atomics.store(barrier, 0, 1);
    Atomics.notify(barrier, 0);
    await Promise.all(exited);
  }

  run().then(common.mustCall());
}

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@panva panva added author ready PRs with CI started, the required approvals, and no outstanding review comments. resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Oct 21, 2026
@github-actions github-actions Bot removed the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 21, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.57%. Comparing base (39e03b4) to head (6781088).
⚠️ Report is 28 commits behind head on main.

Files with missing lines Patch % Lines
src/node.cc 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #66903   +/-   ##
=======================================
  Coverage   90.57%   90.57%           
=======================================
  Files         797      797           
  Lines      278502   278498    -4     
  Branches    53540    53540           
=======================================
  Hits       252247   252247           
- Misses      16592    16601    +9     
+ Partials     9663     9650   -13     
Files with missing lines Coverage Δ
src/node.cc 79.82% <0.00%> (+0.24%) ⬆️

... and 30 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@panva panva added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 21, 2026
@panva

panva commented Oct 21, 2026

Copy link
Copy Markdown
Member Author

I'll let CQ let me know when 48 hours are up (it'll fail on the account of the revert commit message), then i'll land this manually.

@gurgunday gurgunday 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

@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Oct 23, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Commit Queue failed

   ✖  1 GitHub CI job(s) failed:
   ✖    - lint-commit-message: FAILURE (https://github.com/nodejs/node/actions/runs/39635702384/job/119345447700)

The pull request was removed from the Commit Queue and labeled commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. . After resolving the failure, remove that label and add commit-queue PRs queued for automated landing through the Commit Queue. to retry.

Full Commit Queue output
�[36m⠋�[39m Loading data for nodejs/node/pull/66903
�[36m⠋�[39m Loading data for nodejs/node/pull/66903
�[36m⠋�[39m Getting collaborator contacts from README of nodejs/node
�[36m⠋�[39m Getting PR from nodejs/node/pull/66903
�[36m⠋�[39m Getting reviews from nodejs/node/pull/66903
�[36m⠋�[39m Getting comments from nodejs/node/pull/66903
�[36m⠋�[39m Getting commits from nodejs/node/pull/66903
✔  Done loading data for nodejs/node/pull/66903
----------------------------------- PR info ------------------------------------
Title      src: revert V8 entropy source optimization (#66903)
Author     Filip Skokan <panva.ip@gmail.com> (@panva)
Branch     panva:revert-v8-entropy -> nodejs:main
Labels     c++, flaky-test, author ready, needs-ci, revert, commit-queue, commit-queue-rebase, dont-land-on-v22.x, dont-land-on-v24.x
Commits    2
 - Revert "test: mark worker init failure flaky on SmartOS"
 - Revert "src: seed V8 from the OS CSPRNG instead of OpenSSL's DRBG"
Committers 1
 - Filip Skokan <panva.ip@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66903
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/66903
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Wed, 21 Oct 2026 16:32:33 GMT
   ✔  Approvals: 3
   ✔  - Richard Lau (@richardlau) (TSC): https://github.com/nodejs/node/pull/66903#pullrequestreview-5603064339
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/66903#pullrequestreview-5605446842
   ✔  - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/66903#pullrequestreview-5606098823
   ✖  1 GitHub CI job(s) failed:
   ✖    - lint-commit-message: FAILURE (https://github.com/nodejs/node/actions/runs/39635702384/job/119345447700)
   ℹ  Last Full PR CI on 2026-10-21T17:57:55Z: https://ci.nodejs.org/job/node-test-pull-request/78554/
�[36m⠙�[39m Querying data for job/node-test-pull-request/78554/
�[36m⠙�[39m Querying data for job/node-test-pull-request/78554/
�[36m⠙�[39m Querying API for job/node-test-pull-request/78554/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu

View workflow run

@panva panva removed the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Oct 23, 2026
panva added a commit that referenced this pull request Oct 23, 2026
This reverts commit 6ecfd65.

PR-URL: #66903
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
panva added a commit that referenced this pull request Oct 23, 2026
This reverts commit 43d3fe9.

PR-URL: #66903
Reviewed-By: Richard Lau <richard.lau@ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
@panva

panva commented Oct 23, 2026 •

Copy link
Copy Markdown
Member Author

Landed in 03cca65...6511fb8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. dont-land-on-v24.x PRs that should not land on the v24.x-staging branch and should not be released in v24.x. flaky-test Issues and PRs involving tests that fail intermittently in CI. needs-ci PRs that need a full CI run. revert PRs that revert previously landed PRs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants