Skip to main content
MessagePort.prototype.ref - worker_threads - Node documentation
method MessagePort.prototype.ref

Usage in Deno

import { MessagePort } from "node:worker_threads";
MessagePort.prototype.ref(): void

Opposite of unref(). Calling ref() on a previously unref()ed port does not let the program exit if it's the only active handle left (the default behavior). If the port is ref()ed, calling ref() again has no effect.

If listeners are attached or removed using .on('message'), the port is ref()ed and unref()ed automatically depending on whether listeners for the event exist.

Return Type

void