node/test/parallel/test-worker-nearheaplimit-deadlock.js
Michaël Zasso daae938f32
build: enable V8's shared read-only heap
It is what V8's build config does by default.

PR-URL: https://github.com/nodejs/node/pull/42809
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2022-04-24 07:29:13 +01:00

27 lines
815 B
JavaScript

// Flags: --no-node-snapshot
// With node snapshot the OOM can occur during the deserialization of the
// context, so disable it since we want the OOM to occur during the creation of
// the message port.
'use strict';
const common = require('../common');
const assert = require('assert');
const { Worker } = require('worker_threads');
// Do not use isMainThread so that this test itself can be run inside a Worker.
if (!process.env.HAS_STARTED_WORKER) {
process.env.HAS_STARTED_WORKER = 1;
const opts = {
resourceLimits: {
maxYoungGenerationSizeMb: 0,
maxOldGenerationSizeMb: 0
},
};
const worker = new Worker(__filename, opts);
worker.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'ERR_WORKER_OUT_OF_MEMORY');
}));
} else {
setInterval(() => {}, 1);
}