{"action":"created","comment":{"url":"https://api.github.com/repos/josdejong/workerpool/pulls/comments/81614710","pull_request_review_id":2581548,"id":81614710,"diff_hunk":"@@ -80,26 +80,39 @@ function WorkerHandler(script) {\n   }\n \n   var me = this;\n-  this.worker.on('message', function (response) {\n-    // find the task from the processing queue, and run the tasks callback\n-    var id = response.id;\n-    var task = me.processing[id];\n-    if (task) {\n-      // remove the task from the queue\n-      delete me.processing[id];\n-\n-      // test if we need to terminate\n-      if (me.terminating) {\n-        // complete worker termination if all tasks are finished\n-        me.terminate();\n-      }\n \n-      // resolve the task's promise\n-      if (response.error) {\n-        task.resolver.reject(objectToError(response.error));\n-      }\n-      else {\n-        task.resolver.resolve(response.result);\n+  // The ready message is only sent if the worker.add method is called (And the default script is not used)\n+  if (!script) {\n+    this.worker.ready = true;\n+  }\n+\n+  // queue for requests that are received before the worker is ready\n+  this.request_queue = [];","path":"lib/WorkerHandler.js","position":48,"original_position":48,"commit_id":"a5ee50ea25e9a813f3b5c9c60c4aa26719b2baf4","original_commit_id":"a5ee50ea25e9a813f3b5c9c60c4aa26719b2baf4","user":{"login":"josdejong","id":568626,"avatar_url":"https://avatars.githubusercontent.com/u/568626?v=3","gravatar_id":"","url":"https://api.github.com/users/josdejong","html_url":"https://github.com/josdejong","followers_url":"https://api.github.com/users/josdejong/followers","following_url":"https://api.github.com/users/josdejong/following{/other_user}","gists_url":"https://api.github.com/users/josdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/josdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josdejong/subscriptions","organizations_url":"https://api.github.com/users/josdejong/orgs","repos_url":"https://api.github.com/users/josdejong/repos","events_url":"https://api.github.com/users/josdejong/events{/privacy}","received_events_url":"https://api.github.com/users/josdejong/received_events","type":"User","site_admin":false},"body":"Can you please rename `request_queue` to `requestQueue`? Or maybe `taskQueue` or something? At least lowerCamelCase :).","created_at":"2016-10-03T18:49:07Z","updated_at":"2016-10-03T18:52:55Z","html_url":"https://github.com/josdejong/workerpool/pull/15#discussion_r81614710","pull_request_url":"https://api.github.com/repos/josdejong/workerpool/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/josdejong/workerpool/pulls/comments/81614710"},"html":{"href":"https://github.com/josdejong/workerpool/pull/15#discussion_r81614710"},"pull_request":{"href":"https://api.github.com/repos/josdejong/workerpool/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/josdejong/workerpool/pulls/15","id":87667276,"html_url":"https://github.com/josdejong/workerpool/pull/15","diff_url":"https://github.com/josdejong/workerpool/pull/15.diff","patch_url":"https://github.com/josdejong/workerpool/pull/15.patch","issue_url":"https://api.github.com/repos/josdejong/workerpool/issues/15","number":15,"state":"open","locked":false,"title":"Worker ready","user":{"login":"natlibfi-arlehiko","id":7912669,"avatar_url":"https://avatars.githubusercontent.com/u/7912669?v=3","gravatar_id":"","url":"https://api.github.com/users/natlibfi-arlehiko","html_url":"https://github.com/natlibfi-arlehiko","followers_url":"https://api.github.com/users/natlibfi-arlehiko/followers","following_url":"https://api.github.com/users/natlibfi-arlehiko/following{/other_user}","gists_url":"https://api.github.com/users/natlibfi-arlehiko/gists{/gist_id}","starred_url":"https://api.github.com/users/natlibfi-arlehiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natlibfi-arlehiko/subscriptions","organizations_url":"https://api.github.com/users/natlibfi-arlehiko/orgs","repos_url":"https://api.github.com/users/natlibfi-arlehiko/repos","events_url":"https://api.github.com/users/natlibfi-arlehiko/events{/privacy}","received_events_url":"https://api.github.com/users/natlibfi-arlehiko/received_events","type":"User","site_admin":false},"body":"Implement worker 'ready' message  & export environment","created_at":"2016-10-03T06:08:04Z","updated_at":"2016-10-03T18:52:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a3223acfb828be3750ea984b803673b50d991757","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/josdejong/workerpool/pulls/15/commits","review_comments_url":"https://api.github.com/repos/josdejong/workerpool/pulls/15/comments","review_comment_url":"https://api.github.com/repos/josdejong/workerpool/pulls/comments{/number}","comments_url":"https://api.github.com/repos/josdejong/workerpool/issues/15/comments","statuses_url":"https://api.github.com/repos/josdejong/workerpool/statuses/a5ee50ea25e9a813f3b5c9c60c4aa26719b2baf4","head":{"label":"natlibfi-arlehiko:worker-ready","ref":"worker-ready","sha":"a5ee50ea25e9a813f3b5c9c60c4aa26719b2baf4","user":{"login":"natlibfi-arlehiko","id":7912669,"avatar_url":"https://avatars.githubusercontent.com/u/7912669?v=3","gravatar_id":"","url":"https://api.github.com/users/natlibfi-arlehiko","html_url":"https://github.com/natlibfi-arlehiko","followers_url":"https://api.github.com/users/natlibfi-arlehiko/followers","following_url":"https://api.github.com/users/natlibfi-arlehiko/following{/other_user}","gists_url":"https://api.github.com/users/natlibfi-arlehiko/gists{/gist_id}","starred_url":"https://api.github.com/users/natlibfi-arlehiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natlibfi-arlehiko/subscriptions","organizations_url":"https://api.github.com/users/natlibfi-arlehiko/orgs","repos_url":"https://api.github.com/users/natlibfi-arlehiko/repos","events_url":"https://api.github.com/users/natlibfi-arlehiko/events{/privacy}","received_events_url":"https://api.github.com/users/natlibfi-arlehiko/received_events","type":"User","site_admin":false},"repo":{"id":67790420,"name":"workerpool","full_name":"natlibfi-arlehiko/workerpool","owner":{"login":"natlibfi-arlehiko","id":7912669,"avatar_url":"https://avatars.githubusercontent.com/u/7912669?v=3","gravatar_id":"","url":"https://api.github.com/users/natlibfi-arlehiko","html_url":"https://github.com/natlibfi-arlehiko","followers_url":"https://api.github.com/users/natlibfi-arlehiko/followers","following_url":"https://api.github.com/users/natlibfi-arlehiko/following{/other_user}","gists_url":"https://api.github.com/users/natlibfi-arlehiko/gists{/gist_id}","starred_url":"https://api.github.com/users/natlibfi-arlehiko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/natlibfi-arlehiko/subscriptions","organizations_url":"https://api.github.com/users/natlibfi-arlehiko/orgs","repos_url":"https://api.github.com/users/natlibfi-arlehiko/repos","events_url":"https://api.github.com/users/natlibfi-arlehiko/events{/privacy}","received_events_url":"https://api.github.com/users/natlibfi-arlehiko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/natlibfi-arlehiko/workerpool","description":"Offload tasks to a pool of workers on node.js and in the browser","fork":true,"url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool","forks_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/forks","keys_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/teams","hooks_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/hooks","issue_events_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/issues/events{/number}","events_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/events","assignees_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/assignees{/user}","branches_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/branches{/branch}","tags_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/tags","blobs_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/git/refs{/sha}","trees_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/statuses/{sha}","languages_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/languages","stargazers_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/stargazers","contributors_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/contributors","subscribers_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/subscribers","subscription_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/subscription","commits_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/commits{/sha}","git_commits_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/git/commits{/sha}","comments_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/comments{/number}","issue_comment_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/issues/comments{/number}","contents_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/contents/{+path}","compare_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/merges","archive_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/downloads","issues_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/issues{/number}","pulls_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/pulls{/number}","milestones_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/milestones{/number}","notifications_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/labels{/name}","releases_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/releases{/id}","deployments_url":"https://api.github.com/repos/natlibfi-arlehiko/workerpool/deployments","created_at":"2016-09-09T10:33:48Z","updated_at":"2016-09-09T10:33:49Z","pushed_at":"2016-10-03T06:07:09Z","git_url":"git://github.com/natlibfi-arlehiko/workerpool.git","ssh_url":"git@github.com:natlibfi-arlehiko/workerpool.git","clone_url":"https://github.com/natlibfi-arlehiko/workerpool.git","svn_url":"https://github.com/natlibfi-arlehiko/workerpool","homepage":"","size":292,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"josdejong:master","ref":"master","sha":"e92042c57a42e8fedcdf4d731aa30d892f2c5997","user":{"login":"josdejong","id":568626,"avatar_url":"https://avatars.githubusercontent.com/u/568626?v=3","gravatar_id":"","url":"https://api.github.com/users/josdejong","html_url":"https://github.com/josdejong","followers_url":"https://api.github.com/users/josdejong/followers","following_url":"https://api.github.com/users/josdejong/following{/other_user}","gists_url":"https://api.github.com/users/josdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/josdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josdejong/subscriptions","organizations_url":"https://api.github.com/users/josdejong/orgs","repos_url":"https://api.github.com/users/josdejong/repos","events_url":"https://api.github.com/users/josdejong/events{/privacy}","received_events_url":"https://api.github.com/users/josdejong/received_events","type":"User","site_admin":false},"repo":{"id":19384606,"name":"workerpool","full_name":"josdejong/workerpool","owner":{"login":"josdejong","id":568626,"avatar_url":"https://avatars.githubusercontent.com/u/568626?v=3","gravatar_id":"","url":"https://api.github.com/users/josdejong","html_url":"https://github.com/josdejong","followers_url":"https://api.github.com/users/josdejong/followers","following_url":"https://api.github.com/users/josdejong/following{/other_user}","gists_url":"https://api.github.com/users/josdejong/gists{/gist_id}","starred_url":"https://api.github.com/users/josdejong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/josdejong/subscriptions","organizations_url":"https://api.github.com/users/josdejong/orgs","repos_url":"https://api.github.com/users/josdejong/repos","events_url":"https://api.github.com/users/josdejong/events{/privacy}","received_events_url":"https://api.github.com/users/josdejong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/josdejong/workerpool","description":"Offload tasks to a pool of workers on node.js and in the browser","fork":false,"url":"https://api.github.com/repos/josdejong/workerpool","forks_url":"https://api.github.com/repos/josdejong/workerpool/forks","keys_url":"https://api.github.com/repos/josdejong/workerpool/keys{/key_id}","collaborators_url":"https://api.github.com/repos/josdejong/workerpool/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/josdejong/workerpool/teams","hooks_url":"https://api.github.com/repos/josdejong/workerpool/hooks","issue_events_url":"https://api.github.com/repos/josdejong/workerpool/issues/events{/number}","events_url":"https://api.github.com/repos/josdejong/workerpool/events","assignees_url":"https://api.github.com/repos/josdejong/workerpool/assignees{/user}","branches_url":"https://api.github.com/repos/josdejong/workerpool/branches{/branch}","tags_url":"https://api.github.com/repos/josdejong/workerpool/tags","blobs_url":"https://api.github.com/repos/josdejong/workerpool/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/josdejong/workerpool/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/josdejong/workerpool/git/refs{/sha}","trees_url":"https://api.github.com/repos/josdejong/workerpool/git/trees{/sha}","statuses_url":"https://api.github.com/repos/josdejong/workerpool/statuses/{sha}","languages_url":"https://api.github.com/repos/josdejong/workerpool/languages","stargazers_url":"https://api.github.com/repos/josdejong/workerpool/stargazers","contributors_url":"https://api.github.com/repos/josdejong/workerpool/contributors","subscribers_url":"https://api.github.com/repos/josdejong/workerpool/subscribers","subscription_url":"https://api.github.com/repos/josdejong/workerpool/subscription","commits_url":"https://api.github.com/repos/josdejong/workerpool/commits{/sha}","git_commits_url":"https://api.github.com/repos/josdejong/workerpool/git/commits{/sha}","comments_url":"https://api.github.com/repos/josdejong/workerpool/comments{/number}","issue_comment_url":"https://api.github.com/repos/josdejong/workerpool/issues/comments{/number}","contents_url":"https://api.github.com/repos/josdejong/workerpool/contents/{+path}","compare_url":"https://api.github.com/repos/josdejong/workerpool/compare/{base}...{head}","merges_url":"https://api.github.com/repos/josdejong/workerpool/merges","archive_url":"https://api.github.com/repos/josdejong/workerpool/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/josdejong/workerpool/downloads","issues_url":"https://api.github.com/repos/josdejong/workerpool/issues{/number}","pulls_url":"https://api.github.com/repos/josdejong/workerpool/pulls{/number}","milestones_url":"https://api.github.com/repos/josdejong/workerpool/milestones{/number}","notifications_url":"https://api.github.com/repos/josdejong/workerpool/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/josdejong/workerpool/labels{/name}","releases_url":"https://api.github.com/repos/josdejong/workerpool/releases{/id}","deployments_url":"https://api.github.com/repos/josdejong/workerpool/deployments","created_at":"2014-05-02T18:34:29Z","updated_at":"2016-09-29T03:21:56Z","pushed_at":"2016-10-03T18:36:12Z","git_url":"git://github.com/josdejong/workerpool.git","ssh_url":"git@github.com:josdejong/workerpool.git","clone_url":"https://github.com/josdejong/workerpool.git","svn_url":"https://github.com/josdejong/workerpool","homepage":"","size":280,"stargazers_count":142,"watchers_count":142,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":6,"forks":12,"open_issues":6,"watchers":142,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/josdejong/workerpool/pulls/15"},"html":{"href":"https://github.com/josdejong/workerpool/pull/15"},"issue":{"href":"https://api.github.com/repos/josdejong/workerpool/issues/15"},"comments":{"href":"https://api.github.com/repos/josdejong/workerpool/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/josdejong/workerpool/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/josdejong/workerpool/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/josdejong/workerpool/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/josdejong/workerpool/statuses/a5ee50ea25e9a813f3b5c9c60c4aa26719b2baf4"}}}}
{"actor":{"display_login":"josdejong"}}