11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ci// Flags: --expose-internals 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci// Check that main thread handles unserializable errors in a worker thread as 61cb0ef41Sopenharmony_ci// expected. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst common = require('../common'); 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst assert = require('assert'); 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciconst { Worker } = require('worker_threads'); 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_ciconst worker = new Worker(` 151cb0ef41Sopenharmony_ci const { internalBinding } = require('internal/test/binding'); 161cb0ef41Sopenharmony_ci const { getEnvMessagePort } = internalBinding('worker'); 171cb0ef41Sopenharmony_ci const { messageTypes } = require('internal/worker/io'); 181cb0ef41Sopenharmony_ci const messagePort = getEnvMessagePort(); 191cb0ef41Sopenharmony_ci messagePort.postMessage({ type: messageTypes.COULD_NOT_SERIALIZE_ERROR }); 201cb0ef41Sopenharmony_ci`, { eval: true }); 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciworker.on('error', common.mustCall((e) => { 231cb0ef41Sopenharmony_ci assert.strictEqual(e.code, 'ERR_WORKER_UNSERIALIZABLE_ERROR'); 241cb0ef41Sopenharmony_ci})); 25