【问题标题】:Track down a Redis error event追踪 Redis 错误事件
【发布时间】:2015-07-10 16:42:59
【问题描述】:

我的 Node.js 应用程序使用 node-redis npm 模块作为其 redis 客户端。我们在客户端收到一条关于我们的应用程序潜在崩溃的错误消息,但无法追踪它。 redis 客户端收到一个错误事件,带有一个提供崩溃原因的错误对象。不幸的是,字符串“user_id”在我们的代码中使用得非常频繁,以至于很难知道这个问题在代码中的哪个位置发生。关于如何获得更多洞察力的任何想法?

var that = this;
this.redisClient.on("error", function (err) {
    if ( !that.stopped ) {
        Logger.error("Redis Subscribe Client Error =" + err);
    }
});

输出:

Redis Subscribe Client Error =TypeError: Cannot read property 'user_id' of undefined. pid=3571

NPM 模块:https://github.com/mranney/node_redis

【问题讨论】:

    标签: redis


    【解决方案1】:

    err.stack显示堆栈:

    this.redisClient.on("error", function (err) {
       console.log(err.stack);
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-31
      • 2011-11-05
      • 2011-05-10
      • 1970-01-01
      • 2011-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多