You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When trying to write a very basic worker_thread pub sub server/client flow using the "inproc" transport the client subscriber fails to receive the messages.
Reproducing
const{ Worker, isMainThread, parentPort }=require('node:worker_threads');constprocess=require('process')constzmq=require('zeromq/v5-compat')functionresolveOnSignals(...signals){returnnewPromise((resolve)=>{for(constsigofsignals){process.on(sig,()=>resolve(sig))}})}// when using other transport types like ipc and tcp it worksconsturl='inproc://foo'//const url = 'ipc://foo'//const url = 'tcp://127.0.0.1:7301'asyncfunctionpublisher(worker){console.log('Server Started!')constpublisher=zmq.socket('pub')publisher.on('error',(err)=>{console.error('error',err.message)})awaitnewPromise((resolve,reject)=>{publisher.bind(url,(err)=>{if(err){returnreject(err)}resolve()})})leti=0constinterval=setInterval(()=>{constmsg=['weasel',i]console.log('Sending msg',msg)publisher.send(msg)i++},1000)console.info('Waiting for os signal to stop us')conststopReason=awaitPromise.race([resolveOnSignals('SIGINT')])console.info('Asked to stop by %s',stopReason)clearInterval(interval)publisher.close()worker.terminate()return0}asyncfunctionsubscriber(){console.log('Client Started!')constsub=zmq.socket('sub')sub.on('error',(err)=>{console.error('error',err.message)})sub.on('message',(topic,msg)=>{console.log('GOT MSG topic',topic,'MSG=',msg)})sub.connect(url)sub.subscribe('')console.info('Waiting for os signal to stop us')conststopReason=awaitPromise.race([resolveOnSignals('SIGINT')])console.info('Asked to stop by %s',stopReason)sub.close()return0}if(isMainThread){constworker=newWorker(__filename)worker.unref()publisher(worker).then((exitCode)=>{}).catch((err)=>{console.error(err.message)process.exit(1)})}else{subscriber().then((exitCode)=>{}).catch((err)=>{console.error(err.message)process.exit(1)})}
Expected behavior
i expect the message to be printed in the client
and for the client not to crash when causing SIGINT in the process Tested on
OS: MacOS 12.6 (Monterey)
ZeroMQ.js version: 6.0.0-beta.16
The text was updated successfully, but these errors were encountered:
Describe the bug
When trying to write a very basic worker_thread pub sub server/client flow using the "inproc" transport the client subscriber fails to receive the messages.
Reproducing
Expected behavior
i expect the message to be printed in the client
and for the client not to crash when causing SIGINT in the process
Tested on
The text was updated successfully, but these errors were encountered: