Skip to content

worker: resourceLimits overridden by --max-old-space-size #43991

Description

@kvakil

Version

v19.0.0-pre (and earlier)

Platform

Linux sylph 5.4.0-56-generic # 62-Ubuntu SMP Mon Nov 23 19:20:19 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

worker

What steps will reproduce the bug?

If --max-old-space-size is passed on the command line, it takes
precedence over resourceLimits.maxOldSpaceSizeMb passed to the worker
thread.

It seems to come from this code in V8:

if (FLAG_max_old_space_size > 0) {

You can repro by modifying test/parallel/test-worker-resource-limits.js.
Adding a value for--max-old-space-size here (even if it is the default)
causes the test to fail.

diff --git a/test/parallel/test-worker-resource-limits.js b/test/parallel/test-worker-resource-limits.js
index f79c31b2a1..1f394eaa4a 100644
--- a/test/parallel/test-worker-resource-limits.js
+++ b/test/parallel/test-worker-resource-limits.js
@@ -1,3 +1,4 @@
+// Flags: --max-old-space-size=1000
 'use strict';
 const common = require('../common');
 const assert = require('assert');

I feel this is unintuitive and should be changed upstream, but it should
definitely be documented in NodeJS too.

How often does it reproduce? Is there a required condition?

always

What is the expected behavior?

resourceLimits.maxOldSpaceSizeMb should override --max-old-space-size.

What do you see instead?

--max-old-space-size overrides resourceLimits.maxOldSpaceSizeMb.

Additional information

No response

Activity

  1. kvakil commented on Jul 26, 2022

    @kvakil
    ContributorAuthor

    Alternative: introduce a new flag --max-old-space-size-main-thread-only (just an example name).

    Use that flag to initialize the main thread's old space size. Deprecate --max-old-space-size.

    This has the added advantage of removing a dependency on a V8 internal flag.

  2. changed the title [-]worker: resourceLimits overriden by --max-old-space-size[/-] [+]worker: resourceLimits overridden by --max-old-space-size[/+] on Jul 26, 2022
  3. added
    workerIssues and PRs related to the worker_threads module and Worker API.
    on Jul 26, 2022
  4. bnoordhuis commented on Jul 27, 2022

    @bnoordhuis
    Member

    ISTM --max-old-space-size=<n> should take precedence over resourceLimits.maxOldSpaceSizeMb when the former is smaller than the latter. It's okay for a worker to have a heap smaller than the global limit, but not bigger.

  5. kvakil commented on Jul 27, 2022

    @kvakil
    ContributorAuthor
  6. bnoordhuis commented on Jul 27, 2022

    @bnoordhuis
    Member

    The behavior I would like it to have / feel is the least surprising.

  7. github-actions commented on Jun 25, 2026

    @github-actions
    Contributor

    This issue has been marked as stale due to 210 days of inactivity.
    It will be automatically closed in 30 days if no further activity occurs. If this is still relevant, please leave a comment or update it to keep it open.

  8. added
    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.
    on Jun 25, 2026
  9. github-actions commented on Jul 26, 2026

    @github-actions
    Contributor

    This issue has been automatically closed after 30 days of inactivity following its stale status (no activity for a total of 120 days).
    If this is still relevant, feel free to reopen it or leave a comment with additional details so we can continue the discussion.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.workerIssues and PRs related to the worker_threads module and Worker API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions