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

configureExchangesAndQueues does not check for a null profile #5

Open
JAertgeerts opened this issue Jan 6, 2017 · 0 comments
Open

Comments

@JAertgeerts
Copy link

JAertgeerts commented Jan 6, 2017

If the process is no worker, the application shuts down as
TypeError: Cannot read property 'tasks' of undefined

This because profile can be null, as stated in the method configuration (if the process is not a worker). The configure method will fail because you're accessing the profile object in the configureExchangesAndQueues method.

/**
  * configure rabbitmq exchanges, queues, bindings and handlers
  */
 configure() {
   let taskerConfig = this.app.config.tasker
   const profile = getWorkerProfile(taskerConfig)
   taskerConfig = configureExchangesAndQueues(profile, taskerConfig)

   this.app.tasker = new Client(this.app, rabbit, taskerConfig.exchangeName)
   TaskerUtils.registerTasks(profile, this.app, rabbit)

 }

I can open a PR to check if profile is null or do you want to handle it differently?
My current solution is just the following:

 /**
 * configure rabbitmq exchanges, queues, bindings and handlers
 */
configure() {
  let taskerConfig = this.app.config.tasker
  const profile = getWorkerProfile(taskerConfig)
  if (profile) {
    taskerConfig = configureExchangesAndQueues(profile, taskerConfig)

    this.app.tasker = new Client(this.app, rabbit, taskerConfig.exchangeName)
    TaskerUtils.registerTasks(profile, this.app, rabbit)
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant