Offload functions to worker threads with shared memory primitives for Node.js.
8
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(examples): use threadId instead of pid in server-threads example

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+2 -1
+2 -1
examples/server-threads/server.ts
··· 1 1 import { createServer } from 'node:http'; 2 + import { threadId } from 'node:worker_threads'; 2 3 import { mo } from '../../src/index.ts'; 3 4 import { listen, type ListenArgs } from '../../src/serve/index.ts'; 4 5 5 6 export const runServer = mo(import.meta, async (...args: ListenArgs): Promise<void> => { 6 7 const srv = createServer((req, res) => { 7 8 res.writeHead(200, { 'Content-Type': 'text/plain' }); 8 - res.end(`handled by worker ${process.pid}\n`); 9 + res.end(`handled by thread ${threadId}\n`); 9 10 }); 10 11 await listen(srv, ...args); 11 12 });