moleculer
                                
                                 moleculer copied to clipboard
                                
                                    moleculer copied to clipboard
                            
                            
                            
                        moleculer exits without error message
I use moleculer with node-config. App crashes immediately after running without any message. After hours of research, I found maybe the reason is config object is sealed and immutable but moleculer wants to modify it. If moleculer failed to start, why not print some error messages?
const config = require('config')
const {ServiceBroker} = require('moleculer')
const broker = new ServiceBroker(config.get('moleculer'))
broker.start()
  .then(() => {
    console.log('moleculer broker success!')
  })
  .catch((e: any) => {
    console.log('moleculer broker failed!')
  })
From FAQ: If there is no continuously running process (e.g., transporter connection, API gateway, DB connection) that keeps event loop running then the process will exit. It’s normal behavior and not a bug. If you want to keep your service broker running then you should keep the event loop “busy”. Try to enable the transporter in moleculer.config.js.
@AndreMaz There is  transporter connection in moleculer.config.js. The problem is if transporter.options is sealed, Moleculer exits without error message. You can try the following BrokerOptions:
{
  namespace: 'test',
  logLevel: 'warn',
  transporter: {
    type: 'NATS',
    options: Object.seal({
      url: 'nats://nats:4222',
      maxReconnectAttempts: 10
    })
  }
}
Hey @elixiao
Tested over here with your snipped and I got a Unable to create ServiceBroker error that is present in ServiceBroker constructor.

As a workaround you can use lodash cloneDeep function to "unseal" the config. object right before passing it to the constructor. This way the ServiceBroker can modify it and inject default configs.
https://github.com/moleculerjs/moleculer/blob/78b66743e18f8eb706491b60e156bfb9572035a1/src/service-broker.js#L149
@AndreMaz Thanks. Add logger:true to BrokerOptions could show error messages now. Because config.get('xxx') results a deep sealed object. If I don't add logger: true, the app just exits without any output.
const {ServiceBroker} = require('moleculer')
const options = Object.seal({
  namespace: 'test',
  logLevel: 'warn',
  logger: true, // <---- here is the key point, if remove this line, there are no error messages and app just exits
  transporter: Object.seal({
    type: 'NATS',
    options: Object.seal({
      url: 'nats://localhost:4222',
      maxReconnectAttempts: 10
    })
  })
})
const broker = new ServiceBroker(options)
broker.start()
  .then(() => {
    console.log('moleculer broker success!')
  })
  .catch((e) => {
    console.log('moleculer broker failed!')
  })
@elixiao what is your use-case why you are using sealed objects?
@icebob Actually I don't want to use sealed objects. However, node-config returns me a sealed object. I put moleculer BrokerOptions into default.json/production.json in order to connect to different transporter. node-config loads different json file according to different NODE_ENV.

const config = require('config')
const {ServiceBroker} = require('moleculer')
const brokerOptions = config.get('moleculer') // returns a deep sealed object
const broker = new ServiceBroker(brokerOptions)
Please create a repro repo and I will check what we can do to solve it.
@icebob https://github.com/elixiao/moleculer-demo
use node src/ or npm run dev to run demo.
I'm closing this issue, because we don't know, how we can solve it inside Moleculer. If you have idea or solution please reopen or open a PR.