Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Not implemented: cluster.fork #27485

Open
saeho opened this issue Dec 29, 2024 · 1 comment
Open

Error: Not implemented: cluster.fork #27485

saeho opened this issue Dec 29, 2024 · 1 comment

Comments

@saeho
Copy link

saeho commented Dec 29, 2024

Version: Deno v2.1.4

Attempting to use the node:cluster module to cluster.fork() throws an error
Error: Not implemented: cluster.fork

Code to duplicate:

import cluster from 'node:cluster';
import http from 'node:http';
import { availableParallelism } from 'node:os';
import process from 'node:process';

const numCPUs = availableParallelism();

if (cluster.isPrimary) {
  console.log(`Primary ${process.pid} is running`);

  // Fork workers.
  for (let i = 0; i < numCPUs; i++) {
    cluster.fork();
    console.log('fork cpu:', i);
  }
} else {
  // Workers can share any TCP connection
  // In this case it is an HTTP server
  http.createServer((req, res) => {
    res.writeHead(200);
    res.end('hello world\n');
  }).listen(8000);

  console.log(`Worker ${process.pid} started`);
}
@marvinhagemeister
Copy link
Contributor

FYI: The node:cluster module is not supported in Deno at the moment. All module exports are non-functional stubs, see https://docs.deno.com/api/node/cluster/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants