<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg" -->

---
title: Node.js worker threads are problematic, but they work...
description: Node.js's single-threaded event loop means CPU-heavy user code can starve timers and I/O, causing missed heartbeats. Inngest hit this with Connect, its...
canonical: https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Node.js worker threads are problematic, but they work great for us | daily.dev
og:description: Node.js's single-threaded event loop means CPU-heavy user code can starve timers and I/O, causing missed heartbeats. Inngest hit this with Connect, its...
og:url: https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg
og:image: https://api.daily.dev/og/posts/o961Uhafg.png
og:image:alt: Node.js worker threads are problematic, but they work great for us
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js worker threads are problematic, but they work great for us

**[Inngest Blog](https://daily.dev/sources/inngest)** · 11 min read · 0 upvotes · 0 comments

## Summary

Node.js's single-threaded event loop means CPU-heavy user code can starve timers and I/O, causing missed heartbeats. Inngest hit this with Connect, its persistent WebSocket connection: user code monopolizing the main thread blocked heartbeats and made the server think workers were dead. The fix was moving Connect's internals into a worker thread. The piece explains how Node worker threads differ from Go goroutines, Rust threads, and Python threads: you can't pass a closure to a worker, only a file path; communication is message passing via the structured clone algorithm rather than shared memory; bundlers can't statically detect worker files without exact syntax; and each worker is a heavyweight V8 isolate (~10MB overhead) unlike lightweight goroutines. It also covers practical issues encountered while building Connect's worker thread architecture, including routing logger calls across threads and adding exponential backoff for worker respawning after crashes.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.inngest.com/blog/node-worker-threads>

## Questions this post answers

### Why does Node.js miss setInterval heartbeats when CPU-heavy code is running?

Node's event loop can only advance between phases when the current synchronous JavaScript execution yields. A CPU-heavy function running for 30 seconds straight blocks the loop entirely, so a heartbeat scheduled with setInterval every 10 seconds sits queued and never fires until the function returns, potentially causing a server to mark the connection as dead.

_Anyone debugging dropped heartbeats or timed-out connections tracks event loop pitfalls like this via daily.dev._

### Can I pass a closure or function directly to a new Worker in Node.js?

No, Node.js worker threads cannot accept a function or closure the way Go goroutines or Rust threads do. The structured clone algorithm used to serialize data between threads cannot serialize functions, so you must point new Worker() at a separate file with its own entry point and imports, making it closer to a microservice than a spawned task.

_Developers weighing Node worker threads against goroutines or Rust threads compare these tradeoffs on daily.dev._

### How much memory overhead does each Node.js worker thread add compared to a goroutine?

Each Node.js worker thread runs as a full V8 isolate with its own heap and event loop, adding roughly 10 MB of memory overhead and a startup cost in the tens of milliseconds. Goroutines, by contrast, start at only a few kilobytes, so a Go program can comfortably run thousands of them while Node worker pools stay limited to a small number of long-lived workers.

_Engineers sizing worker pools or comparing runtime concurrency costs keep this kind of benchmark handy through daily.dev._

## Similar posts on daily.dev

- [Stop Calling Node.js “Single-Threaded”: A Look Under the Hood](https://daily.dev/posts/stop-calling-node-js-single-threaded-a-look-under-the-hood-ofsmhbjmm) · Medium · 6 upvotes · 0 comments
- [Cloudflare Workers Accept Inbound TCP, with gRPC the First Protocol on Top](https://daily.dev/posts/cloudflare-workers-accept-inbound-tcp-with-grpc-the-first-protocol-on-top-pplojcdxn) · InfoQ · 0 upvotes · 0 comments
- [Issue \#643: When worker threads beat processes for Node efficiency — Node Weekly](https://daily.dev/posts/issue-643-when-worker-threads-beat-processes-for-node-efficiency-node-weekly-g9gk0zefc) · Node Weekly · 4 upvotes · 0 comments
- [W4G1/multithreading: The missing standard library for multithreading in JavaScript \(Works in Node.js, Deno, Bun, Web browser\)](https://daily.dev/posts/w4g1-multithreading-the-missing-standard-library-for-multithreading-in-javascript-works-in-node-js-ipxwage4k) · Hacker News · 3 upvotes · 0 comments
- [How workerd, the Cloudflare Workers runtime, is built](https://daily.dev/posts/how-workerd-the-cloudflare-workers-runtime-is-built-jripr3oyh) · Flavio Copes · 0 upvotes · 0 comments

---

Tags: [#inngest](https://daily.dev/tags/inngest), [#nodejs](https://daily.dev/tags/nodejs)

[View this post on daily.dev](https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Node.js worker threads are problematic, but they work great for us","url":"https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg"},"datePublished":"2026-09-13T19:57:22.963Z","dateModified":"2026-10-15T02:22:38.758Z","description":"Node.js's single-threaded event loop means CPU-heavy user code can starve timers and I/O, causing missed heartbeats. Inngest hit this with Connect, its...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/dda591b3e4bd935d2190f398e0178616?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/dda591b3e4bd935d2190f398e0178616?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Inngest Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Inngest Blog","logo":"https://media.daily.dev/image/upload/s--ieZKUa5y--/c_limit,w_256/f_auto,q_auto/v1789329423/logos/inngest?_a=BAMAMicg0","url":"https://daily.dev/sources/inngest"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"inngest,nodejs","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Inngest Blog","item":"https://daily.dev/sources/inngest"},{"@type":"ListItem","position":3,"name":"Node.js worker threads are problematic, but they work great for us"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/node-js-worker-threads-are-problematic-but-they-work-great-for-us-o961uhafg#faq","mainEntity":[{"@type":"Question","name":"Why does Node.js miss setInterval heartbeats when CPU-heavy code is running?","acceptedAnswer":{"@type":"Answer","text":"Node's event loop can only advance between phases when the current synchronous JavaScript execution yields. A CPU-heavy function running for 30 seconds straight blocks the loop entirely, so a heartbeat scheduled with setInterval every 10 seconds sits queued and never fires until the function returns, potentially causing a server to mark the connection as dead. Anyone debugging dropped heartbeats or timed-out connections tracks event loop pitfalls like this via daily.dev."}},{"@type":"Question","name":"Can I pass a closure or function directly to a new Worker in Node.js?","acceptedAnswer":{"@type":"Answer","text":"No, Node.js worker threads cannot accept a function or closure the way Go goroutines or Rust threads do. The structured clone algorithm used to serialize data between threads cannot serialize functions, so you must point new Worker() at a separate file with its own entry point and imports, making it closer to a microservice than a spawned task. Developers weighing Node worker threads against goroutines or Rust threads compare these tradeoffs on daily.dev."}},{"@type":"Question","name":"How much memory overhead does each Node.js worker thread add compared to a goroutine?","acceptedAnswer":{"@type":"Answer","text":"Each Node.js worker thread runs as a full V8 isolate with its own heap and event loop, adding roughly 10 MB of memory overhead and a startup cost in the tens of milliseconds. Goroutines, by contrast, start at only a few kilobytes, so a Go program can comfortably run thousands of them while Node worker pools stay limited to a small number of long-lived workers. Engineers sizing worker pools or comparing runtime concurrency costs keep this kind of benchmark handy through daily.dev."}}]}
```

