{"action":"created","issue":{"url":"https://api.github.com/repos/d3/d3-queue/issues/54","labels_url":"https://api.github.com/repos/d3/d3-queue/issues/54/labels{/name}","comments_url":"https://api.github.com/repos/d3/d3-queue/issues/54/comments","events_url":"https://api.github.com/repos/d3/d3-queue/issues/54/events","html_url":"https://github.com/d3/d3-queue/issues/54","id":129566954,"number":54,"title":"d3_queue Uncaught Error","user":{"login":"staircaseblog","id":11777010,"avatar_url":"https://avatars.githubusercontent.com/u/11777010?v=3","gravatar_id":"","url":"https://api.github.com/users/staircaseblog","html_url":"https://github.com/staircaseblog","followers_url":"https://api.github.com/users/staircaseblog/followers","following_url":"https://api.github.com/users/staircaseblog/following{/other_user}","gists_url":"https://api.github.com/users/staircaseblog/gists{/gist_id}","starred_url":"https://api.github.com/users/staircaseblog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/staircaseblog/subscriptions","organizations_url":"https://api.github.com/users/staircaseblog/orgs","repos_url":"https://api.github.com/users/staircaseblog/repos","events_url":"https://api.github.com/users/staircaseblog/events{/privacy}","received_events_url":"https://api.github.com/users/staircaseblog/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-28T20:16:11Z","updated_at":"2016-01-28T20:25:02Z","closed_at":"2016-01-28T20:25:02Z","body":"Hi, i had a working setup with d3 queue. For some reason it does not work any more and i have no clue after two days. I updated to the latest version. Exactly the same behaviour. To some extent i believe it has nothing to do with d3_queue itself. It just happens to it.\r\n\r\nThe code bails on first use of defer. Nothing is done by defer, it seems to fail immediately. If i am going in the browser console and instantiate a new instance it works. \r\n\r\n(http://uhvauerr.de/ --> login with defaults --> select any marker --> error)\r\n\r\n```js\r\nvar lade = function(rahmen, cback){\r\n        var url = \"/api/v2/datad3?rahmen=\" + rahmen + \"&geraet=\" + geraet;\r\n\r\n        d3.json(url).header('X-Access-Token', token).header('X-Key', user).get(function (error, data) {\r\n            cback(error, data);\r\n        });\r\n    };\r\n\r\n    var taskqueue = d3_queue.queue(2);\r\n    var frameurl = \"/api/v2/frames?geraet=\" + geraet;\r\n\r\n    d3.json(frameurl).header('X-Access-Token', token).header('X-Key', user).get(function(error, data){\r\n        $.each(data, function (index, frame) {\r\n            console.log(frame.rahmen);\r\n            taskqueue.defer(lade, frame.rahmen); //<<<<<<<<<<<<<<<<<<<<<<<<ERROR HERE\r\n        });\r\n    });\r\n\r\n    taskqueue.awaitAll(function(error, results) {\r\n\r\n        //console.log(results);\r\n        var data = [];\r\n\r\n        results.forEach(function (c, i, a) {\r\n            console.log(c);\r\n            //c.knoten_id;\r\n            c.datensaetze.forEach(function (d, j, a) {\r\n                d.key = \"\" + (c.knoten_id) + \"_\" + d.key; // WORKAROUND Rahmen id sollte vom json file kommen\r\n                data.push(d);\r\n            });\r\n        });\r\n\r\n        console.log(data);\r\n\r\n        if(data.length != 0) {\r\n            makeGraph(data);\r\n        }\r\n    });\r\n ```\r\n\r\n```\r\nUncaught Error\r\nc.defer @ d3-queue.min.js:1\r\n(anonymous function) @ VM484:135\r\nn.extend.each @ jquery-2.2.0.min.js:2\r\n(anonymous function) @ VM484:133\r\n(anonymous function) @ d3.js:1899\r\nevent @ d3.js:434\r\nrespond @ d3.js:1852\r\n```"},"comment":{"url":"https://api.github.com/repos/d3/d3-queue/issues/comments/176394126","html_url":"https://github.com/d3/d3-queue/issues/54#issuecomment-176394126","issue_url":"https://api.github.com/repos/d3/d3-queue/issues/54","id":176394126,"user":{"login":"mbostock","id":230541,"avatar_url":"https://avatars.githubusercontent.com/u/230541?v=3","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","site_admin":false},"created_at":"2016-01-28T20:25:02Z","updated_at":"2016-01-28T20:25:02Z","body":"The issue is that you’ve set your awaitAll callback before deferring your tasks. Specifically, you’re calling `taskqueue.defer` in your d3.json callback, which happens *after* you (synchronously) called `taskqueue.awaitAll`.\r\n\r\nYou must call *queue*.await or *queue*.awaitAll after any calls to *queue*.defer. This is so that you get one (and exactly one) notification of when your queue of tasks has finished.\r\n\r\nIn this case, I’d move the construction of the queue into after your d3.json callback.\r\n\r\n```js\r\nd3.json(frameurl).header('X-Access-Token', token).header('X-Key', user).get(function(error, data){\r\n  if (error) throw error; // If the initial request fails…\r\n  var taskqueue = d3_queue.queue(2);\r\n  $.each(data, function (index, frame) {\r\n    taskqueue.defer(lade, frame.rahmen)\r\n  });\r\n  taskqueue.awaitAll(function(error, results) {\r\n    if (error) throw error; // If a queued request fails…\r\n    console.log(results);\r\n  });\r\n});\r\n```"}}