node icon indicating copy to clipboard operation
node copied to clipboard

src: allow --disallow-code-generation-from-strings in workers

Open mcollina opened this issue 1 month ago • 5 comments

Make --disallow-code-generation-from-strings a per-isolate option instead of a V8-only option, allowing it to be passed via worker execArgv.

Fixes: https://github.com/nodejs/node/issues/60371

mcollina avatar Nov 02 '25 12:11 mcollina

Review requested:

  • [ ] @nodejs/config

nodejs-github-bot avatar Nov 02 '25 12:11 nodejs-github-bot

cc @legendecas I presume this is incorrect then.

mcollina avatar Nov 02 '25 22:11 mcollina

I presume this is incorrect then.

My comment at https://github.com/nodejs/node/issues/60371#issuecomment-3478332501 was answering the question "why aren't v8 options supported for a worker thread?" and to most V8 options, we should not change them for a single worker.

However, we declared a same name flag --disallow-code-generation-from-strings in Node.js (it was derived from the V8 flag). It is safe if we didn't use the APIs like V8::SetFlagsFromString, which sets the per-process V8 flag storage.

In short, I think this PR should be good.

legendecas avatar Nov 02 '25 22:11 legendecas

@legendcas @addaleax can you take another look? This should be ready.

mcollina avatar Nov 19 '25 11:11 mcollina

Codecov Report

:x: Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 88.52%. Comparing base (9bfff20) to head (971be87). :warning: Report is 340 commits behind head on main.

Files with missing lines Patch % Lines
src/api/environment.cc 80.00% 1 Missing and 2 partials :warning:
src/node_worker.cc 66.66% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60549      +/-   ##
==========================================
- Coverage   88.58%   88.52%   -0.07%     
==========================================
  Files         704      703       -1     
  Lines      207777   208447     +670     
  Branches    40033    40196     +163     
==========================================
+ Hits       184068   184525     +457     
- Misses      15755    15936     +181     
- Partials     7954     7986      +32     
Files with missing lines Coverage Δ
src/node.h 95.91% <ø> (ø)
src/node_contextify.cc 82.45% <ø> (+0.66%) :arrow_up:
src/node_internals.h 83.01% <ø> (ø)
src/node_options.cc 77.90% <ø> (+0.06%) :arrow_up:
src/node_options.h 97.90% <100.00%> (+0.04%) :arrow_up:
src/node_worker.cc 81.64% <66.66%> (+0.03%) :arrow_up:
src/api/environment.cc 76.59% <80.00%> (-0.25%) :arrow_down:

... and 133 files with indirect coverage changes

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

codecov[bot] avatar Nov 19 '25 12:11 codecov[bot]