1// Flags: --no-node-snapshot 2// With node snapshot the OOM can occur during the deserialization of the 3// context, so disable it since we want the OOM to occur during the creation of 4// the message port. 5'use strict'; 6const common = require('../common'); 7const assert = require('assert'); 8const { Worker } = require('worker_threads'); 9 10// Do not use isMainThread so that this test itself can be run inside a Worker. 11if (!process.env.HAS_STARTED_WORKER) { 12 process.env.HAS_STARTED_WORKER = 1; 13 const opts = { 14 resourceLimits: { 15 maxYoungGenerationSizeMb: 0, 16 maxOldGenerationSizeMb: 0 17 }, 18 }; 19 20 const worker = new Worker(__filename, opts); 21 worker.on('error', common.mustCall((err) => { 22 assert.strictEqual(err.code, 'ERR_WORKER_OUT_OF_MEMORY'); 23 })); 24} else { 25 setInterval(() => {}, 1); 26} 27