Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ResourceLimits don't work for node:worker_threads #26156

Open
josephrocca opened this issue Oct 11, 2024 · 1 comment
Open

ResourceLimits don't work for node:worker_threads #26156

josephrocca opened this issue Oct 11, 2024 · 1 comment
Labels
bug Something isn't working correctly node compat

Comments

@josephrocca
Copy link
Contributor

josephrocca commented Oct 11, 2024

Version: Deno v2.0.0 (tested as far back as v1.41.3)

Below is a simplified version of this test:

import worker_threads from 'node:worker_threads';
const worker = new worker_threads.Worker(new URL("./worker.mjs", import.meta.url), {
  resourceLimits: {
    maxYoungGenerationSizeMb: 4,
    maxOldGenerationSizeMb: 16,
    codeRangeSizeMb: 16,
    stackSizeMb: 1,
  },
});

And here's ./worker.mjs:

import { resourceLimits } from 'node:worker_threads';
console.log(resourceLimits);

In Node.js it logs this:

resourceLimits: {
  maxYoungGenerationSizeMb: 4,
  maxOldGenerationSizeMb: 16,
  codeRangeSizeMb: 16,
  stackSizeMb: 1
}

And a simple large string allocation test shows that the limit is respected - i.e. it crashes with FATAL ERROR: Reached heap limit Allocation failed if the limit is hit.

In Deno it logs the default values:

resourceLimits: {
  maxYoungGenerationSizeMb: 48,
  maxOldGenerationSizeMb: 2048,
  codeRangeSizeMb: 0,
  stackSizeMb: 4
}

Related Context:

@lucacasonato
Copy link
Member

@josephrocca Are you suggesting that Deno is respecting the set resource limits, but it is not showing the correct values? Or are you saying it does neither?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly node compat
Projects
None yet
Development

No branches or pull requests

3 participants