Files
scriptc/tests/fixtures/node-island/exit-tls.cjs
T
Malte UblandClaude Opus 5.5 55a69232b7 Exit cleanly with Node loaded and keep nested entries on Node's stack (NI-7c, NI-3b)
Node islands stack, part 8 of 11 (scriptc-perf/results/islands-prs/PLAN.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 18:49:55 -07:00

17 lines
759 B
JavaScript

// Island work that keeps OpenSSL busy while the program exits
// (exit-tls.mjs): loading node:tls starts Node's off-thread loading of the
// root certificates (system ones with NODE_USE_SYSTEM_CA=1, extra ones with
// NODE_EXTRA_CA_CERTS); pbkdf2 and key generation run on libuv's pool.
"use strict";
const crypto = require("node:crypto");
const tls = require("node:tls");
exports.warm = function warm(mode) {
if (mode === "load") return tls.DEFAULT_MIN_VERSION.length > 0;
tls.createSecureContext();
const roots = tls.rootCertificates.length > 0;
for (let i = 0; i < 8; i++) crypto.pbkdf2("password", "salt", 20000, 64, "sha512", () => {});
if (mode === "keys") crypto.generateKeyPair("ec", { namedCurve: "P-256" }, () => {});
return roots;
};