1'use strict'; 2 3// Flags: --expose-internals 4 5// Check that main thread handles unserializable errors in a worker thread as 6// expected. 7 8const common = require('../common'); 9 10const assert = require('assert'); 11 12const { Worker } = require('worker_threads'); 13 14const worker = new Worker(` 15 const { internalBinding } = require('internal/test/binding'); 16 const { getEnvMessagePort } = internalBinding('worker'); 17 const { messageTypes } = require('internal/worker/io'); 18 const messagePort = getEnvMessagePort(); 19 messagePort.postMessage({ type: messageTypes.COULD_NOT_SERIALIZE_ERROR }); 20`, { eval: true }); 21 22worker.on('error', common.mustCall((e) => { 23 assert.strictEqual(e.code, 'ERR_WORKER_UNSERIALIZABLE_ERROR'); 24})); 25