GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — worker: display MessagePort status in util.inspect() · nodejs/node@1daa82a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • worker.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/worker.js‎

Copy file name to clipboardExpand all lines: lib/internal/worker.js
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,27 @@ MessagePort.prototype.close = function(cb) {
125125
const drainMessagePort = MessagePort.prototype.drain;
126126
delete MessagePort.prototype.drain;
127127

128+
Object.defineProperty(MessagePort.prototype, util.inspect.custom, {
129+
enumerable: false,
130+
writable: false,
131+
value: function inspect() { // eslint-disable-line func-name-matching
132+
let ref;
133+
try {
134+
// This may throw when `this` does not refer to a native object,
135+
// e.g. when accessing the prototype directly.
136+
ref = this.hasRef();
137+
} catch { return this; }
138+
return Object.assign(Object.create(MessagePort.prototype),
139+
ref === undefined ? {
140+
active: false,
141+
} : {
142+
active: true,
143+
refed: ref
144+
},
145+
this);
146+
}
147+
});
148+
128149
function setupPortReferencing(port, eventEmitter, eventName) {
129150
// Keep track of whether there are any workerMessage listeners:
130151
// If there are some, ref() the channel so it keeps the event loop alive.

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.