0

In the past, I've seen that using a MessageChannel or MessagePort will prevent my process from exiting when it is done.

I see there's an .unref() method on MessagePort that can be called, but the docs aren't very clear on how best to use it.

Do I need to wait until all messages have been sent/received before calling .unref()? Will calling it prevent messages from being delivered? Or can I call it as soon as it's created? In addition, do I need to call .unref() on both ends of a MessageChannel, or just one of them?

Ken White
  • 123,280
  • 14
  • 225
  • 444
Sophie Alpert
  • 139,698
  • 36
  • 220
  • 238

0 Answers0