How to use the kafka-node/lib/errors.TopicsNotExistError function in kafka-node

To help you get started, we’ve selected a few kafka-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github deepstreamIO / deepstream.io-msg-kafka / src / message-connector.js View on Github external
const _internalCallback = (err, arg) => {
      if (err) {
        if(err instanceof kafkaErrors.TopicsNotExistError) {
          this._producer.createTopics([topic], false, (err) => {
            if(err) {
              // Error creating topic:
              origCallback(err)
              return
            }
            // Topic created, retry:
            methodCallback(origCallback)
          })
          return
        }

        // Sometimes kafka will throw a strange error in the form of an Array.
        // This is probably related to the deployment of the actual kafka
        // or zookeeper service as it only happens once, when the server hasn't
        // been accessed for a while.