firebase-queue初始化失败

时间:2016-09-28 14:52:43

标签: node.js firebase firebase-realtime-database firebase-queue

我的Firebase队列初始化失败,错误如下。我正在使用Firebase 3。

Task was malformed

堆栈跟踪

"Error: Task was malformed\n    at Object.update
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase-queue/dist/lib/queue_worker.js:446:27)\n
at ei
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:217:395)\n
at U.h.transaction
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:232:466)\n
at
/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase-queue/dist/lib/queue_worker.js:439:30\n
at c
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:153:58)\n
at
/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:144:614\n
at Qb
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:43:165)\n
at sc
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:31:216)\n
at rc
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:30:1104)\n
at yg
(/Users/kanishkanagaraj/JeetLab/BetMe/firebase-queue/node_modules/firebase/database-node.js:215:313)"

我的代码:

var ref = firebase.database().ref('queue');
    var queue = new Queue(ref, function(data, progress, resolve, reject) {

      console.log(data);


       // Do some work
      progress(50);

      // Finish the task asynchronously
      setTimeout(function() {
        resolve();
      }, 1000);

1 个答案:

答案 0 :(得分:1)

那是因为你试图添加一个只是一个字符串的任务,你需要添加一个对象,它应该是这样的:

{
  "queue": {
    "tasks": {
      "someKey": {
        "foo": true
      }
    }
  }
}