js-ipfs
js-ipfs copied to clipboard
TypeError: obj.address is not a function when ran in a Node cluster
-
Version:
[email protected] -
Platform:
Arch Linux Lenovo-Y530 5.15.13-arch1-1 #1 SMP PREEMPT Wed, 05 Jan 2022 16:20:59 +0000 x86_64 GNU/Linux -
Subsystem: n/a
Severity: High(?)
Description:
-
What you did Tried to create ipfs-core node in a Node.js cluster worker.
-
What happened Got error and program crashed.
TypeError: obj.address is not a function
at Socket.<anonymous> (node:internal/cluster/child:115:25)
at Object.onceWrapper (node:events:509:28)
at Socket.emit (node:events:402:35)
at startListening (node:dgram:173:10)
at node:dgram:223:5
at shared (node:internal/cluster/child:149:3)
at Worker.<anonymous> (node:internal/cluster/child:106:7)
at process.onInternalMessage (node:internal/cluster/utils:49:5)
at process.emit (node:events:402:35)
at processEmit [as emit] (/data/sync/programming/praca/ipfs-repro/node_modules/signal-exit/index.js:197:34)
- What you expected to happen
IPFS node should be created successfully and print some information like:
Swarm listening on...
Steps to reproduce the error:
Run the following code using Node.JS v17.3.0,
import cluster from "cluster";
import * as ipfs from "ipfs-core";
if(cluster.isPrimary) {
cluster.fork();
} else {
const ipfsNode = ipfs.create();
}
This is a simplest reproduction I managed to find. My actual usecase is that I'm writing a node js server bundled by webpack and started using start-server-nestjs-webpack-plugin plugin. I'm using this plugin to archive hot module replacement, however it seems to starts the code inside a cluster worker which prevents ipfs-core from working correctly.