Repository navigation
Conversation
|
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 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());
} |
|
Review requested:
|
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
|
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. |
Commit Queue failedThe pull request was removed from the Commit Queue and labeled
commit-queue-failed
Full Commit Queue output |
|
Landed in 03cca65...6511fb8 |
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 marktest-worker-init-failureflaky on SmartOS because of descriptor-dependent entropy failures. Now I'm seeing intermittenttest-crypto-x509failures 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.