xref: /third_party/node/test/parallel/test-worker-message-port-inspect-during-init-hook.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/test/parallel/
11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ciconst util = require('util');
41cb0ef41Sopenharmony_ciconst assert = require('assert');
51cb0ef41Sopenharmony_ciconst async_hooks = require('async_hooks');
61cb0ef41Sopenharmony_ciconst { MessageChannel } = require('worker_threads');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci// Regression test: Inspecting a `MessagePort` object before it is finished
91cb0ef41Sopenharmony_ci// constructing does not crash the process.
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_ciasync_hooks.createHook({
121cb0ef41Sopenharmony_ci  init: common.mustCall((id, type, triggerId, resource) => {
131cb0ef41Sopenharmony_ci    assert.strictEqual(
141cb0ef41Sopenharmony_ci      util.inspect(resource),
151cb0ef41Sopenharmony_ci      'MessagePort [EventTarget] { active: true, refed: false }');
161cb0ef41Sopenharmony_ci  }, 2)
171cb0ef41Sopenharmony_ci}).enable();
181cb0ef41Sopenharmony_ci
191cb0ef41Sopenharmony_ciconst { port1 } = new MessageChannel();
201cb0ef41Sopenharmony_ciconst inspection = util.inspect(port1);
211cb0ef41Sopenharmony_ciassert(inspection.includes('active: true'));
221cb0ef41Sopenharmony_ciassert(inspection.includes('refed: false'));
23

Indexes created Thu Nov 07 10:32:03 CST 2024