Best way to trigger worker_thread OOM exception in Node.js

July 28, 2022, at 9:10 PM

I would like to test code that reports when a worker_thread OOMs. Or at least that the parent is OK despite the thread crashing due to OOM reasons. I would like to specifically test Node.js killing a worker_thread.

I'm not even sure this is particularly testable since the environment in which Node.js is running seems to make a difference. Setting low old generation size (docs) using resource limits does not behave the way I thought it would, it seems Node.js and the OS are doing a lot of clever things to keep the process from blowing up in memory. The closest I have gotten is that both Node.js AND the worker are killed. But again, this is not the behaviour I was expecting - Node.js should be killing the worker.

Is there any way to reliably test for something like this? Currently running v16.13.2.


Here is some sample JS for the worker:

const { isMainThread } = require('worker_threads');
if (!isMainThread) {
  let as = [];
  for (let i = 0; i < 100; i++) {
    let a = '';
    for (let i = 0; i < 9000000; i++) a += i.toString();
Answer 1

OK, it looks like adding maxYoungGenerationSizeMb in my case is resulting in the behaviour I was looking for: e.g. { maxOldGenerationSizeMb: 10, maxYoungGenerationSizeMb: 10 }.

Rent Charter Buses Company
Firebase Cloud Functions: PubSub, &quot;res.on is not a function&quot;

Firebase Cloud Functions: PubSub, "res.on is not a function"

Im trying to use the etherscan API by using an axiospost() function

TypeError: Cannot read properties of undefined (reading &#39;createMessageComponentCollector&#39;)

TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')

Im trying to fix this error that I keep getting when I run /help, and don't know what I did wrong, I tried to do what I could with the error, but im getting annoyed at this point

AWS XRAY on Fargate service

AWS XRAY on Fargate service

I want to add xray to my Fargate serviceEverything works (synth/deploy) but in the logs I'am seeing the following error:

How to resolve getting Error 429 Imgur Api

How to resolve getting Error 429 Imgur Api

I'm making an image management system through discord, uploading images on Imgur throug it's apiI know my code was wrong, cause i was trying to upload like 125 images at the exact same time for the initialization of the system, and i got (temp, i think)...