Skip to content

fix: forward string env vars to cluster.fork() so NODE_EXTRA_CA_CERTS etc. actually apply - #6155

Closed
kiboook wants to merge 1 commit into
Unitech:masterfrom
kiboook:fix/cluster-node-extra-ca-certs-v2
Closed

kiboook wants to merge 1 commit into
Unitech:masterfrom
kiboook:fix/cluster-node-extra-ca-certs-v2

Conversation

@kiboook

@kiboook kiboook commented Sep 9, 2026 •

Copy link
Copy Markdown

closed

… etc. actually apply

cluster.fork() was only called with {pm2_env, windowsHide}, so none of
the app's own env vars exist as real env vars in the worker at boot
time - they only get set later, after pm2_env is parsed. That's too
late for anything Node reads once during TLS bootstrap, NODE_EXTRA_CA_CERTS
being the most common case people run into with a private CA.

Fixes Unitech#5919. A narrow fix for just this one var was proposed back in
Unitech#3117 but never landed. This does the same thing more generally: every
string-typed key in env_copy gets forwarded as a real env var too,
alongside pm2_env. Non-string values are skipped on purpose, that's
what pm2_env/[object Object] leak issue Unitech#6073 was about.

Reproduced locally with a private CA + a small HTTPS server: cluster
mode failed with UNABLE_TO_VERIFY_LEAF_SIGNATURE even though
process.env.NODE_EXTRA_CA_CERTS was correctly set inside the worker,
which confirms it's a timing issue and not a missing value. Added
test/programmatic/issue_5919_node_extra_ca_certs.mocha.js, which fails
without this patch and passes with it. Existing cluster/env tests
(including issue_6073) still pass.
@kiboook

kiboook commented Sep 9, 2026

Copy link
Copy Markdown
Author

Closing, will reopen from a different branch.

@kiboook kiboook closed this Sep 9, 2026
@kiboook
kiboook deleted the fix/cluster-node-extra-ca-certs-v2 branch September 9, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant