{"action":"created","comment":{"url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/comments/41712090","id":41712090,"diff_hunk":"@@ -16,44 +16,35 @@ export class NodeSubmissionClient extends DefaultSubmissionClient {\n     this.configurationVersionHeader = this.configurationVersionHeader.toLowerCase();\n   }\n \n-  public sendRequest(config:Configuration, method:string, path:string, data:string, callback: (status:number, message:string, data?:string, headers?:Object) => void): void {\n-    function complete(response:http.IncomingMessage, responseBody:string, responseHeaders:Object) {\n-      var message:string;\n-      if (response.statusCode === 0) {\n-        message = 'Unable to connect to server.';\n-      } else if (response.statusCode < 200 || response.statusCode > 299) {\n-        message = response.statusMessage || (<any>response).message;\n-      }\n+  public sendRequest(config: Configuration, method: string, path: string, data: string, callback: NodeSubmissionCallback): void {\n+    var request: NodeSubmissionRequest = {\n+      method,\n+      path,\n+      data,\n+      serverUrl: config.serverUrl,\n+      apiKey: config.apiKey,\n+      userAgent: config.userAgent\n+    };\n \n-      callback(response.statusCode || 500, message, responseBody, responseHeaders);\n+    var exitController = config.exitController;\n+    if (exitController.isApplicationExiting) {\n+      this.sendRequestSync(request, callback);\n+    } else {\n+      submitRequest(request, callback);\n     }\n+  }\n \n-    var parsedHost = url.parse(config.serverUrl);\n-    var options:https.RequestOptions = {\n-      auth: `client:${config.apiKey}`,\n-      headers: {},\n-      hostname: parsedHost.hostname,\n-      method: method,\n-      port: parsedHost.port && parseInt(parsedHost.port),\n-      path: path\n-    };\n+  private sendRequestSync(request: NodeSubmissionRequest, callback: NodeSubmissionCallback): void {","path":"src/submission/NodeSubmissionClient.ts","position":55,"original_position":55,"commit_id":"2b420485922823d4260cd9a71c284f3edb8916f5","original_commit_id":"2b420485922823d4260cd9a71c284f3edb8916f5","user":{"login":"ejsmith","id":282584,"avatar_url":"https://avatars.githubusercontent.com/u/282584?v=3","gravatar_id":"","url":"https://api.github.com/users/ejsmith","html_url":"https://github.com/ejsmith","followers_url":"https://api.github.com/users/ejsmith/followers","following_url":"https://api.github.com/users/ejsmith/following{/other_user}","gists_url":"https://api.github.com/users/ejsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/ejsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejsmith/subscriptions","organizations_url":"https://api.github.com/users/ejsmith/orgs","repos_url":"https://api.github.com/users/ejsmith/repos","events_url":"https://api.github.com/users/ejsmith/events{/privacy}","received_events_url":"https://api.github.com/users/ejsmith/received_events","type":"User","site_admin":false},"body":"I am not an expert with Node. Guessing this is the only way to do a synchronous http request?","created_at":"2015-10-11T15:50:15Z","updated_at":"2015-10-11T15:50:15Z","html_url":"https://github.com/exceptionless/Exceptionless.JavaScript/pull/30#discussion_r41712090","pull_request_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30","_links":{"self":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/comments/41712090"},"html":{"href":"https://github.com/exceptionless/Exceptionless.JavaScript/pull/30#discussion_r41712090"},"pull_request":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30"}}},"pull_request":{"url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30","id":47099065,"html_url":"https://github.com/exceptionless/Exceptionless.JavaScript/pull/30","diff_url":"https://github.com/exceptionless/Exceptionless.JavaScript/pull/30.diff","patch_url":"https://github.com/exceptionless/Exceptionless.JavaScript/pull/30.patch","issue_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues/30","number":30,"state":"open","locked":false,"title":"Fix: Log unhandled exceptions in Node.js","user":{"login":"frankebersoll","id":1266582,"avatar_url":"https://avatars.githubusercontent.com/u/1266582?v=3","gravatar_id":"","url":"https://api.github.com/users/frankebersoll","html_url":"https://github.com/frankebersoll","followers_url":"https://api.github.com/users/frankebersoll/followers","following_url":"https://api.github.com/users/frankebersoll/following{/other_user}","gists_url":"https://api.github.com/users/frankebersoll/gists{/gist_id}","starred_url":"https://api.github.com/users/frankebersoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankebersoll/subscriptions","organizations_url":"https://api.github.com/users/frankebersoll/orgs","repos_url":"https://api.github.com/users/frankebersoll/repos","events_url":"https://api.github.com/users/frankebersoll/events{/privacy}","received_events_url":"https://api.github.com/users/frankebersoll/received_events","type":"User","site_admin":false},"body":"This is the first pull request for issue #29.\r\n\r\nIt adds an `IExitController` which is responsible for behavior when the application is exiting. If `isApplicationExiting` is true, `NodeSubmissionClient` will use synchronous event submission. A child process will be spawned synchronously, and pipes are used to transmit the request and response data.\r\n\r\nTry it out using the following test:\r\n\r\n```TypeScript\r\nvar client = require(\"./dist/exceptionless.node.js\").ExceptionlessClient.default;\r\nvar spawnSync = require(\"child_process\").spawnSync;\r\nvar events = require(\"events\");\r\n\r\nclient.config.apiKey = \"WHATEVER\";\r\nclient.config.useDebugLogger();\r\n\r\nthrow new Error(\"Test: Error\");\r\n```","created_at":"2015-10-08T00:21:05Z","updated_at":"2015-10-11T15:50:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"716e3144f438a75254656e64aa8d0ac7e4ab0665","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30/commits","review_comments_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30/comments","review_comment_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues/30/comments","statuses_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/statuses/2b420485922823d4260cd9a71c284f3edb8916f5","head":{"label":"frankebersoll:master","ref":"master","sha":"2b420485922823d4260cd9a71c284f3edb8916f5","user":{"login":"frankebersoll","id":1266582,"avatar_url":"https://avatars.githubusercontent.com/u/1266582?v=3","gravatar_id":"","url":"https://api.github.com/users/frankebersoll","html_url":"https://github.com/frankebersoll","followers_url":"https://api.github.com/users/frankebersoll/followers","following_url":"https://api.github.com/users/frankebersoll/following{/other_user}","gists_url":"https://api.github.com/users/frankebersoll/gists{/gist_id}","starred_url":"https://api.github.com/users/frankebersoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankebersoll/subscriptions","organizations_url":"https://api.github.com/users/frankebersoll/orgs","repos_url":"https://api.github.com/users/frankebersoll/repos","events_url":"https://api.github.com/users/frankebersoll/events{/privacy}","received_events_url":"https://api.github.com/users/frankebersoll/received_events","type":"User","site_admin":false},"repo":{"id":43026537,"name":"Exceptionless.JavaScript","full_name":"frankebersoll/Exceptionless.JavaScript","owner":{"login":"frankebersoll","id":1266582,"avatar_url":"https://avatars.githubusercontent.com/u/1266582?v=3","gravatar_id":"","url":"https://api.github.com/users/frankebersoll","html_url":"https://github.com/frankebersoll","followers_url":"https://api.github.com/users/frankebersoll/followers","following_url":"https://api.github.com/users/frankebersoll/following{/other_user}","gists_url":"https://api.github.com/users/frankebersoll/gists{/gist_id}","starred_url":"https://api.github.com/users/frankebersoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/frankebersoll/subscriptions","organizations_url":"https://api.github.com/users/frankebersoll/orgs","repos_url":"https://api.github.com/users/frankebersoll/repos","events_url":"https://api.github.com/users/frankebersoll/events{/privacy}","received_events_url":"https://api.github.com/users/frankebersoll/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/frankebersoll/Exceptionless.JavaScript","description":"Exceptionless JavaScript client","fork":true,"url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript","forks_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/forks","keys_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/teams","hooks_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/hooks","issue_events_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/issues/events{/number}","events_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/events","assignees_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/assignees{/user}","branches_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/branches{/branch}","tags_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/tags","blobs_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/statuses/{sha}","languages_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/languages","stargazers_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/stargazers","contributors_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/contributors","subscribers_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/subscribers","subscription_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/subscription","commits_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/contents/{+path}","compare_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/merges","archive_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/downloads","issues_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/issues{/number}","pulls_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/pulls{/number}","milestones_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/milestones{/number}","notifications_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/labels{/name}","releases_url":"https://api.github.com/repos/frankebersoll/Exceptionless.JavaScript/releases{/id}","created_at":"2015-09-23T20:57:50Z","updated_at":"2015-10-09T08:52:39Z","pushed_at":"2015-10-09T23:16:30Z","git_url":"git://github.com/frankebersoll/Exceptionless.JavaScript.git","ssh_url":"git@github.com:frankebersoll/Exceptionless.JavaScript.git","clone_url":"https://github.com/frankebersoll/Exceptionless.JavaScript.git","svn_url":"https://github.com/frankebersoll/Exceptionless.JavaScript","homepage":null,"size":1753,"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":"exceptionless:master","ref":"master","sha":"78757e4c936eba4e19e1bce7151df974da79b45c","user":{"login":"exceptionless","id":5912469,"avatar_url":"https://avatars.githubusercontent.com/u/5912469?v=3","gravatar_id":"","url":"https://api.github.com/users/exceptionless","html_url":"https://github.com/exceptionless","followers_url":"https://api.github.com/users/exceptionless/followers","following_url":"https://api.github.com/users/exceptionless/following{/other_user}","gists_url":"https://api.github.com/users/exceptionless/gists{/gist_id}","starred_url":"https://api.github.com/users/exceptionless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exceptionless/subscriptions","organizations_url":"https://api.github.com/users/exceptionless/orgs","repos_url":"https://api.github.com/users/exceptionless/repos","events_url":"https://api.github.com/users/exceptionless/events{/privacy}","received_events_url":"https://api.github.com/users/exceptionless/received_events","type":"Organization","site_admin":false},"repo":{"id":29558878,"name":"Exceptionless.JavaScript","full_name":"exceptionless/Exceptionless.JavaScript","owner":{"login":"exceptionless","id":5912469,"avatar_url":"https://avatars.githubusercontent.com/u/5912469?v=3","gravatar_id":"","url":"https://api.github.com/users/exceptionless","html_url":"https://github.com/exceptionless","followers_url":"https://api.github.com/users/exceptionless/followers","following_url":"https://api.github.com/users/exceptionless/following{/other_user}","gists_url":"https://api.github.com/users/exceptionless/gists{/gist_id}","starred_url":"https://api.github.com/users/exceptionless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/exceptionless/subscriptions","organizations_url":"https://api.github.com/users/exceptionless/orgs","repos_url":"https://api.github.com/users/exceptionless/repos","events_url":"https://api.github.com/users/exceptionless/events{/privacy}","received_events_url":"https://api.github.com/users/exceptionless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/exceptionless/Exceptionless.JavaScript","description":"Exceptionless JavaScript client","fork":false,"url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript","forks_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/forks","keys_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/teams","hooks_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/hooks","issue_events_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues/events{/number}","events_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/events","assignees_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/assignees{/user}","branches_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/branches{/branch}","tags_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/tags","blobs_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/git/refs{/sha}","trees_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/statuses/{sha}","languages_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/languages","stargazers_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/stargazers","contributors_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/contributors","subscribers_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/subscribers","subscription_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/subscription","commits_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/commits{/sha}","git_commits_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/git/commits{/sha}","comments_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/comments{/number}","issue_comment_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues/comments{/number}","contents_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/contents/{+path}","compare_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/merges","archive_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/downloads","issues_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues{/number}","pulls_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls{/number}","milestones_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/milestones{/number}","notifications_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/labels{/name}","releases_url":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/releases{/id}","created_at":"2015-01-20T22:38:28Z","updated_at":"2015-07-21T20:35:00Z","pushed_at":"2015-10-09T21:41:35Z","git_url":"git://github.com/exceptionless/Exceptionless.JavaScript.git","ssh_url":"git@github.com:exceptionless/Exceptionless.JavaScript.git","clone_url":"https://github.com/exceptionless/Exceptionless.JavaScript.git","svn_url":"https://github.com/exceptionless/Exceptionless.JavaScript","homepage":null,"size":2285,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":13,"forks":4,"open_issues":13,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30"},"html":{"href":"https://github.com/exceptionless/Exceptionless.JavaScript/pull/30"},"issue":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues/30"},"comments":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/issues/30/comments"},"review_comments":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30/comments"},"review_comment":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/pulls/30/commits"},"statuses":{"href":"https://api.github.com/repos/exceptionless/Exceptionless.JavaScript/statuses/2b420485922823d4260cd9a71c284f3edb8916f5"}}}}