{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/memchaser/pulls/comments/25767938","id":25767938,"diff_hunk":"@@ -108,27 +104,43 @@ Logger.prototype._writeAsync = function Logger_writeAsync(aMessage, aCallback) {\n   // For testing purposes send the message to stdout\n   //dump(aMessage + '\\n');\n \n-  // Create an output stream to write to file\n-  var foStream = Cc[\"@mozilla.org/network/file-output-stream;1\"]\n-                 .createInstance(Ci.nsIFileOutputStream);\n-  foStream.init(this._file, 0x02 | 0x08 | 0x10, PERMS_FILE, foStream.DEFER_OPEN);\n-\n-  // Write asynchronously to buffer;\n-  // Input and output streams are closed after write\n-  var iStream = this._converter.convertToInputStream(aMessage);\n-  NetUtil.asyncCopy(iStream, foStream, function (status) {\n-    if (!components.isSuccessCode(status)) {\n-      var errorMessage = new Error(\"Error while writing to file: \" + status);\n-      console.error(errorMessage);\n+  function callback() {\n+    if (typeof(aCallback) === \"function\") {\n+      try {\n+        aCallback();\n+      } catch (e) {\n+        Cu.reportError(e);\n+      }\n     }\n+  }\n \n-    if (typeof(aCallback) === \"function\") {\n-      aCallback(status);\n+  let array = this._encoder.encode(aMessage);\n+  let promise = OS.File.open(this.file.path, {write: true})\n+  .then(file => {\n+    file.setPosition(0, OS.File.POS_END)\n+    .then(file.write(array))\n+    .then(\n+      bytes => {\n+        file.close();\n+        callback();\n+      },\n+      error => {\n+        file.close();\n+        callback();\n+    })\n+  })\n+  .then(null, error => {\n+    // Extract something meaningful from WorkerErrorEvent\n+    if (typeof error == \"object\" && error && error.constructor.name == \"WorkerErrorEvent\") {","path":"extension/lib/logger.js","position":67,"original_position":67,"commit_id":"d7098e7b1cfc70352d049daf536c6e9bd245ec24","original_commit_id":"d7098e7b1cfc70352d049daf536c6e9bd245ec24","user":{"login":"whimboo","id":129603,"avatar_url":"https://avatars.githubusercontent.com/u/129603?v=3","gravatar_id":"","url":"https://api.github.com/users/whimboo","html_url":"https://github.com/whimboo","followers_url":"https://api.github.com/users/whimboo/followers","following_url":"https://api.github.com/users/whimboo/following{/other_user}","gists_url":"https://api.github.com/users/whimboo/gists{/gist_id}","starred_url":"https://api.github.com/users/whimboo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whimboo/subscriptions","organizations_url":"https://api.github.com/users/whimboo/orgs","repos_url":"https://api.github.com/users/whimboo/repos","events_url":"https://api.github.com/users/whimboo/events{/privacy}","received_events_url":"https://api.github.com/users/whimboo/received_events","type":"User","site_admin":false},"body":"If you end-up here you always have a valid error, so I don't see a reason for all the checks.","created_at":"2015-03-04T11:26:50Z","updated_at":"2015-03-04T11:26:50Z","html_url":"https://github.com/mozilla/memchaser/pull/211#discussion_r25767938","pull_request_url":"https://api.github.com/repos/mozilla/memchaser/pulls/211","_links":{"self":{"href":"https://api.github.com/repos/mozilla/memchaser/pulls/comments/25767938"},"html":{"href":"https://github.com/mozilla/memchaser/pull/211#discussion_r25767938"},"pull_request":{"href":"https://api.github.com/repos/mozilla/memchaser/pulls/211"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/memchaser/pulls/211","id":29399304,"html_url":"https://github.com/mozilla/memchaser/pull/211","diff_url":"https://github.com/mozilla/memchaser/pull/211.diff","patch_url":"https://github.com/mozilla/memchaser/pull/211.patch","issue_url":"https://api.github.com/repos/mozilla/memchaser/issues/211","number":211,"state":"open","locked":false,"title":"Rewrite Logger.prototype._writeAsync() to use OSFile.jsm","user":{"login":"xabolcs","id":568751,"avatar_url":"https://avatars.githubusercontent.com/u/568751?v=3","gravatar_id":"","url":"https://api.github.com/users/xabolcs","html_url":"https://github.com/xabolcs","followers_url":"https://api.github.com/users/xabolcs/followers","following_url":"https://api.github.com/users/xabolcs/following{/other_user}","gists_url":"https://api.github.com/users/xabolcs/gists{/gist_id}","starred_url":"https://api.github.com/users/xabolcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xabolcs/subscriptions","organizations_url":"https://api.github.com/users/xabolcs/orgs","repos_url":"https://api.github.com/users/xabolcs/repos","events_url":"https://api.github.com/users/xabolcs/events{/privacy}","received_events_url":"https://api.github.com/users/xabolcs/received_events","type":"User","site_admin":false},"body":"Fix for #208:\r\n* FIFO based backend for `_writeAsync`\r\n* a test which fails a lot without this fix :)","created_at":"2015-02-16T20:38:35Z","updated_at":"2015-03-04T11:26:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74d85b0ad62cb7d5902448d7ad4fdcdead326d63","assignee":{"login":"xabolcs","id":568751,"avatar_url":"https://avatars.githubusercontent.com/u/568751?v=3","gravatar_id":"","url":"https://api.github.com/users/xabolcs","html_url":"https://github.com/xabolcs","followers_url":"https://api.github.com/users/xabolcs/followers","following_url":"https://api.github.com/users/xabolcs/following{/other_user}","gists_url":"https://api.github.com/users/xabolcs/gists{/gist_id}","starred_url":"https://api.github.com/users/xabolcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xabolcs/subscriptions","organizations_url":"https://api.github.com/users/xabolcs/orgs","repos_url":"https://api.github.com/users/xabolcs/repos","events_url":"https://api.github.com/users/xabolcs/events{/privacy}","received_events_url":"https://api.github.com/users/xabolcs/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/memchaser/pulls/211/commits","review_comments_url":"https://api.github.com/repos/mozilla/memchaser/pulls/211/comments","review_comment_url":"https://api.github.com/repos/mozilla/memchaser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/memchaser/issues/211/comments","statuses_url":"https://api.github.com/repos/mozilla/memchaser/statuses/d7098e7b1cfc70352d049daf536c6e9bd245ec24","head":{"label":"xabolcs:branch-issue-208-logger-promise-worker","ref":"branch-issue-208-logger-promise-worker","sha":"d7098e7b1cfc70352d049daf536c6e9bd245ec24","user":{"login":"xabolcs","id":568751,"avatar_url":"https://avatars.githubusercontent.com/u/568751?v=3","gravatar_id":"","url":"https://api.github.com/users/xabolcs","html_url":"https://github.com/xabolcs","followers_url":"https://api.github.com/users/xabolcs/followers","following_url":"https://api.github.com/users/xabolcs/following{/other_user}","gists_url":"https://api.github.com/users/xabolcs/gists{/gist_id}","starred_url":"https://api.github.com/users/xabolcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xabolcs/subscriptions","organizations_url":"https://api.github.com/users/xabolcs/orgs","repos_url":"https://api.github.com/users/xabolcs/repos","events_url":"https://api.github.com/users/xabolcs/events{/privacy}","received_events_url":"https://api.github.com/users/xabolcs/received_events","type":"User","site_admin":false},"repo":{"id":8762547,"name":"memchaser","full_name":"xabolcs/memchaser","owner":{"login":"xabolcs","id":568751,"avatar_url":"https://avatars.githubusercontent.com/u/568751?v=3","gravatar_id":"","url":"https://api.github.com/users/xabolcs","html_url":"https://github.com/xabolcs","followers_url":"https://api.github.com/users/xabolcs/followers","following_url":"https://api.github.com/users/xabolcs/following{/other_user}","gists_url":"https://api.github.com/users/xabolcs/gists{/gist_id}","starred_url":"https://api.github.com/users/xabolcs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xabolcs/subscriptions","organizations_url":"https://api.github.com/users/xabolcs/orgs","repos_url":"https://api.github.com/users/xabolcs/repos","events_url":"https://api.github.com/users/xabolcs/events{/privacy}","received_events_url":"https://api.github.com/users/xabolcs/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/xabolcs/memchaser","description":"Bugfix fork of MemChaser","fork":true,"url":"https://api.github.com/repos/xabolcs/memchaser","forks_url":"https://api.github.com/repos/xabolcs/memchaser/forks","keys_url":"https://api.github.com/repos/xabolcs/memchaser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/xabolcs/memchaser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/xabolcs/memchaser/teams","hooks_url":"https://api.github.com/repos/xabolcs/memchaser/hooks","issue_events_url":"https://api.github.com/repos/xabolcs/memchaser/issues/events{/number}","events_url":"https://api.github.com/repos/xabolcs/memchaser/events","assignees_url":"https://api.github.com/repos/xabolcs/memchaser/assignees{/user}","branches_url":"https://api.github.com/repos/xabolcs/memchaser/branches{/branch}","tags_url":"https://api.github.com/repos/xabolcs/memchaser/tags","blobs_url":"https://api.github.com/repos/xabolcs/memchaser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/xabolcs/memchaser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/xabolcs/memchaser/git/refs{/sha}","trees_url":"https://api.github.com/repos/xabolcs/memchaser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/xabolcs/memchaser/statuses/{sha}","languages_url":"https://api.github.com/repos/xabolcs/memchaser/languages","stargazers_url":"https://api.github.com/repos/xabolcs/memchaser/stargazers","contributors_url":"https://api.github.com/repos/xabolcs/memchaser/contributors","subscribers_url":"https://api.github.com/repos/xabolcs/memchaser/subscribers","subscription_url":"https://api.github.com/repos/xabolcs/memchaser/subscription","commits_url":"https://api.github.com/repos/xabolcs/memchaser/commits{/sha}","git_commits_url":"https://api.github.com/repos/xabolcs/memchaser/git/commits{/sha}","comments_url":"https://api.github.com/repos/xabolcs/memchaser/comments{/number}","issue_comment_url":"https://api.github.com/repos/xabolcs/memchaser/issues/comments{/number}","contents_url":"https://api.github.com/repos/xabolcs/memchaser/contents/{+path}","compare_url":"https://api.github.com/repos/xabolcs/memchaser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/xabolcs/memchaser/merges","archive_url":"https://api.github.com/repos/xabolcs/memchaser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/xabolcs/memchaser/downloads","issues_url":"https://api.github.com/repos/xabolcs/memchaser/issues{/number}","pulls_url":"https://api.github.com/repos/xabolcs/memchaser/pulls{/number}","milestones_url":"https://api.github.com/repos/xabolcs/memchaser/milestones{/number}","notifications_url":"https://api.github.com/repos/xabolcs/memchaser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/xabolcs/memchaser/labels{/name}","releases_url":"https://api.github.com/repos/xabolcs/memchaser/releases{/id}","created_at":"2013-03-13T22:04:43Z","updated_at":"2015-02-10T14:47:41Z","pushed_at":"2015-02-16T21:48:56Z","git_url":"git://github.com/xabolcs/memchaser.git","ssh_url":"git@github.com:xabolcs/memchaser.git","clone_url":"https://github.com/xabolcs/memchaser.git","svn_url":"https://github.com/xabolcs/memchaser","homepage":"","size":672,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"mozilla:master","ref":"master","sha":"4a1cada77f7718b4cd15cae832d7824bc8d5fc50","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":3109755,"name":"memchaser","full_name":"mozilla/memchaser","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars.githubusercontent.com/u/131524?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/memchaser","description":"Firefox extension to chase the memory usage and garbage collector activity","fork":false,"url":"https://api.github.com/repos/mozilla/memchaser","forks_url":"https://api.github.com/repos/mozilla/memchaser/forks","keys_url":"https://api.github.com/repos/mozilla/memchaser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/memchaser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/memchaser/teams","hooks_url":"https://api.github.com/repos/mozilla/memchaser/hooks","issue_events_url":"https://api.github.com/repos/mozilla/memchaser/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/memchaser/events","assignees_url":"https://api.github.com/repos/mozilla/memchaser/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/memchaser/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/memchaser/tags","blobs_url":"https://api.github.com/repos/mozilla/memchaser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/memchaser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/memchaser/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/memchaser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/memchaser/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/memchaser/languages","stargazers_url":"https://api.github.com/repos/mozilla/memchaser/stargazers","contributors_url":"https://api.github.com/repos/mozilla/memchaser/contributors","subscribers_url":"https://api.github.com/repos/mozilla/memchaser/subscribers","subscription_url":"https://api.github.com/repos/mozilla/memchaser/subscription","commits_url":"https://api.github.com/repos/mozilla/memchaser/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/memchaser/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/memchaser/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/memchaser/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/memchaser/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/memchaser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/memchaser/merges","archive_url":"https://api.github.com/repos/mozilla/memchaser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/memchaser/downloads","issues_url":"https://api.github.com/repos/mozilla/memchaser/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/memchaser/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/memchaser/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/memchaser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/memchaser/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/memchaser/releases{/id}","created_at":"2012-01-05T11:53:21Z","updated_at":"2015-02-10T14:50:16Z","pushed_at":"2015-02-10T14:50:16Z","git_url":"git://github.com/mozilla/memchaser.git","ssh_url":"git@github.com:mozilla/memchaser.git","clone_url":"https://github.com/mozilla/memchaser.git","svn_url":"https://github.com/mozilla/memchaser","homepage":"https://wiki.mozilla.org/QA/Automation_Services/Projects/Addons/MemChaser","size":716,"stargazers_count":31,"watchers_count":31,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":44,"forks":19,"open_issues":44,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/memchaser/pulls/211"},"html":{"href":"https://github.com/mozilla/memchaser/pull/211"},"issue":{"href":"https://api.github.com/repos/mozilla/memchaser/issues/211"},"comments":{"href":"https://api.github.com/repos/mozilla/memchaser/issues/211/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/memchaser/pulls/211/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/memchaser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/memchaser/pulls/211/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/memchaser/statuses/d7098e7b1cfc70352d049daf536c6e9bd245ec24"}}}}