{"action":"created","comment":{"url":"https://api.github.com/repos/nodejs/node/pulls/comments/41440132","id":41440132,"diff_hunk":"@@ -370,8 +370,10 @@ Buffer.prototype.toString = function() {\n   } else {\n     var result = slowToString.apply(this, arguments);\n   }\n-  if (result === undefined)\n-    throw new Error('toString failed');\n+  if (result === undefined) {\n+    throw new RangeError('toString() failed: buffer larger than maximum ' +\n+                         'string size ' + binding.kStringMaxLength + ' bytes');","path":"lib/buffer.js","position":8,"original_position":8,"commit_id":"c511b4a24ac36cc1703ecce2be172dab0a24077a","original_commit_id":"c511b4a24ac36cc1703ecce2be172dab0a24077a","user":{"login":"mhart","id":367936,"avatar_url":"https://avatars.githubusercontent.com/u/367936?v=3","gravatar_id":"","url":"https://api.github.com/users/mhart","html_url":"https://github.com/mhart","followers_url":"https://api.github.com/users/mhart/followers","following_url":"https://api.github.com/users/mhart/following{/other_user}","gists_url":"https://api.github.com/users/mhart/gists{/gist_id}","starred_url":"https://api.github.com/users/mhart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhart/subscriptions","organizations_url":"https://api.github.com/users/mhart/orgs","repos_url":"https://api.github.com/users/mhart/repos","events_url":"https://api.github.com/users/mhart/events{/privacy}","received_events_url":"https://api.github.com/users/mhart/received_events","type":"User","site_admin":false},"body":"I think it should be `string size of 268435440 bytes` – reads oddly without the `of`","created_at":"2015-10-07T20:11:50Z","updated_at":"2015-10-07T20:11:50Z","html_url":"https://github.com/nodejs/node/pull/3243#discussion_r41440132","pull_request_url":"https://api.github.com/repos/nodejs/node/pulls/3243","_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments/41440132"},"html":{"href":"https://github.com/nodejs/node/pull/3243#discussion_r41440132"},"pull_request":{"href":"https://api.github.com/repos/nodejs/node/pulls/3243"}}},"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/3243","id":47072634,"html_url":"https://github.com/nodejs/node/pull/3243","diff_url":"https://github.com/nodejs/node/pull/3243.diff","patch_url":"https://github.com/nodejs/node/pull/3243.patch","issue_url":"https://api.github.com/repos/nodejs/node/issues/3243","number":3243,"state":"open","locked":false,"title":"buffer: More useful error when .toString() fails","user":{"login":"TheAlphaNerd","id":498775,"avatar_url":"https://avatars.githubusercontent.com/u/498775?v=3","gravatar_id":"","url":"https://api.github.com/users/TheAlphaNerd","html_url":"https://github.com/TheAlphaNerd","followers_url":"https://api.github.com/users/TheAlphaNerd/followers","following_url":"https://api.github.com/users/TheAlphaNerd/following{/other_user}","gists_url":"https://api.github.com/users/TheAlphaNerd/gists{/gist_id}","starred_url":"https://api.github.com/users/TheAlphaNerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheAlphaNerd/subscriptions","organizations_url":"https://api.github.com/users/TheAlphaNerd/orgs","repos_url":"https://api.github.com/users/TheAlphaNerd/repos","events_url":"https://api.github.com/users/TheAlphaNerd/events{/privacy}","received_events_url":"https://api.github.com/users/TheAlphaNerd/received_events","type":"User","site_admin":false},"body":"Fixes: #3175\r\n\r\nAs brought up by @mhart in #3175 the current error message for buffer.toString() is not very helpful. The new message reports that the failure is due to the buffer being larger than the maximum string size, and reports that value.\r\n\r\nThis is able to be done without any changes to the code as the only code path that will return ```undefined``` is when length > kMaxLength.\r\n\r\nhttps://github.com/nodejs/node/blob/64beab0fc55f750bae648e9b69e027f2dbf3b18a/deps/v8/include/v8.h#L2294-L2324\r\n\r\nIn a conversation on irc with @trevnorris a test was performed to verify that there does not appear to be a scenario where StringBytes::Encode() could throw that would allow slowToString() to also throw.\r\n\r\n\"since it should be impossible for it to throw otherwise, and explicitly returning an empty handle means String::kMaxLength was exceeded.\" ~ @trevnorris","created_at":"2015-10-07T19:43:46Z","updated_at":"2015-10-07T20:11:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7dea0b0a52bfc726ef3db699762715290d476f0c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nodejs/node/pulls/3243/commits","review_comments_url":"https://api.github.com/repos/nodejs/node/pulls/3243/comments","review_comment_url":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nodejs/node/issues/3243/comments","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/c511b4a24ac36cc1703ecce2be172dab0a24077a","head":{"label":"TheAlphaNerd:BufferToStringErrorMessage","ref":"BufferToStringErrorMessage","sha":"c511b4a24ac36cc1703ecce2be172dab0a24077a","user":{"login":"TheAlphaNerd","id":498775,"avatar_url":"https://avatars.githubusercontent.com/u/498775?v=3","gravatar_id":"","url":"https://api.github.com/users/TheAlphaNerd","html_url":"https://github.com/TheAlphaNerd","followers_url":"https://api.github.com/users/TheAlphaNerd/followers","following_url":"https://api.github.com/users/TheAlphaNerd/following{/other_user}","gists_url":"https://api.github.com/users/TheAlphaNerd/gists{/gist_id}","starred_url":"https://api.github.com/users/TheAlphaNerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheAlphaNerd/subscriptions","organizations_url":"https://api.github.com/users/TheAlphaNerd/orgs","repos_url":"https://api.github.com/users/TheAlphaNerd/repos","events_url":"https://api.github.com/users/TheAlphaNerd/events{/privacy}","received_events_url":"https://api.github.com/users/TheAlphaNerd/received_events","type":"User","site_admin":false},"repo":{"id":43775272,"name":"node","full_name":"TheAlphaNerd/node","owner":{"login":"TheAlphaNerd","id":498775,"avatar_url":"https://avatars.githubusercontent.com/u/498775?v=3","gravatar_id":"","url":"https://api.github.com/users/TheAlphaNerd","html_url":"https://github.com/TheAlphaNerd","followers_url":"https://api.github.com/users/TheAlphaNerd/followers","following_url":"https://api.github.com/users/TheAlphaNerd/following{/other_user}","gists_url":"https://api.github.com/users/TheAlphaNerd/gists{/gist_id}","starred_url":"https://api.github.com/users/TheAlphaNerd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheAlphaNerd/subscriptions","organizations_url":"https://api.github.com/users/TheAlphaNerd/orgs","repos_url":"https://api.github.com/users/TheAlphaNerd/repos","events_url":"https://api.github.com/users/TheAlphaNerd/events{/privacy}","received_events_url":"https://api.github.com/users/TheAlphaNerd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TheAlphaNerd/node","description":"✨Node.js  ✨","fork":true,"url":"https://api.github.com/repos/TheAlphaNerd/node","forks_url":"https://api.github.com/repos/TheAlphaNerd/node/forks","keys_url":"https://api.github.com/repos/TheAlphaNerd/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TheAlphaNerd/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TheAlphaNerd/node/teams","hooks_url":"https://api.github.com/repos/TheAlphaNerd/node/hooks","issue_events_url":"https://api.github.com/repos/TheAlphaNerd/node/issues/events{/number}","events_url":"https://api.github.com/repos/TheAlphaNerd/node/events","assignees_url":"https://api.github.com/repos/TheAlphaNerd/node/assignees{/user}","branches_url":"https://api.github.com/repos/TheAlphaNerd/node/branches{/branch}","tags_url":"https://api.github.com/repos/TheAlphaNerd/node/tags","blobs_url":"https://api.github.com/repos/TheAlphaNerd/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TheAlphaNerd/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TheAlphaNerd/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/TheAlphaNerd/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TheAlphaNerd/node/statuses/{sha}","languages_url":"https://api.github.com/repos/TheAlphaNerd/node/languages","stargazers_url":"https://api.github.com/repos/TheAlphaNerd/node/stargazers","contributors_url":"https://api.github.com/repos/TheAlphaNerd/node/contributors","subscribers_url":"https://api.github.com/repos/TheAlphaNerd/node/subscribers","subscription_url":"https://api.github.com/repos/TheAlphaNerd/node/subscription","commits_url":"https://api.github.com/repos/TheAlphaNerd/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/TheAlphaNerd/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/TheAlphaNerd/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/TheAlphaNerd/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/TheAlphaNerd/node/contents/{+path}","compare_url":"https://api.github.com/repos/TheAlphaNerd/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TheAlphaNerd/node/merges","archive_url":"https://api.github.com/repos/TheAlphaNerd/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TheAlphaNerd/node/downloads","issues_url":"https://api.github.com/repos/TheAlphaNerd/node/issues{/number}","pulls_url":"https://api.github.com/repos/TheAlphaNerd/node/pulls{/number}","milestones_url":"https://api.github.com/repos/TheAlphaNerd/node/milestones{/number}","notifications_url":"https://api.github.com/repos/TheAlphaNerd/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TheAlphaNerd/node/labels{/name}","releases_url":"https://api.github.com/repos/TheAlphaNerd/node/releases{/id}","created_at":"2015-10-06T20:04:38Z","updated_at":"2015-10-06T20:04:58Z","pushed_at":"2015-10-07T20:10:51Z","git_url":"git://github.com/TheAlphaNerd/node.git","ssh_url":"git@github.com:TheAlphaNerd/node.git","clone_url":"https://github.com/TheAlphaNerd/node.git","svn_url":"https://github.com/TheAlphaNerd/node","homepage":"https://nodejs.org","size":148887,"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":"nodejs:master","ref":"master","sha":"aeee956ac73de7af914b747926168714fe4d1c4c","user":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"repo":{"id":27193779,"name":"node","full_name":"nodejs/node","owner":{"login":"nodejs","id":9950313,"avatar_url":"https://avatars.githubusercontent.com/u/9950313?v=3","gravatar_id":"","url":"https://api.github.com/users/nodejs","html_url":"https://github.com/nodejs","followers_url":"https://api.github.com/users/nodejs/followers","following_url":"https://api.github.com/users/nodejs/following{/other_user}","gists_url":"https://api.github.com/users/nodejs/gists{/gist_id}","starred_url":"https://api.github.com/users/nodejs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nodejs/subscriptions","organizations_url":"https://api.github.com/users/nodejs/orgs","repos_url":"https://api.github.com/users/nodejs/repos","events_url":"https://api.github.com/users/nodejs/events{/privacy}","received_events_url":"https://api.github.com/users/nodejs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/nodejs/node","description":"✨Node.js  ✨","fork":false,"url":"https://api.github.com/repos/nodejs/node","forks_url":"https://api.github.com/repos/nodejs/node/forks","keys_url":"https://api.github.com/repos/nodejs/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nodejs/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nodejs/node/teams","hooks_url":"https://api.github.com/repos/nodejs/node/hooks","issue_events_url":"https://api.github.com/repos/nodejs/node/issues/events{/number}","events_url":"https://api.github.com/repos/nodejs/node/events","assignees_url":"https://api.github.com/repos/nodejs/node/assignees{/user}","branches_url":"https://api.github.com/repos/nodejs/node/branches{/branch}","tags_url":"https://api.github.com/repos/nodejs/node/tags","blobs_url":"https://api.github.com/repos/nodejs/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nodejs/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nodejs/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/nodejs/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nodejs/node/statuses/{sha}","languages_url":"https://api.github.com/repos/nodejs/node/languages","stargazers_url":"https://api.github.com/repos/nodejs/node/stargazers","contributors_url":"https://api.github.com/repos/nodejs/node/contributors","subscribers_url":"https://api.github.com/repos/nodejs/node/subscribers","subscription_url":"https://api.github.com/repos/nodejs/node/subscription","commits_url":"https://api.github.com/repos/nodejs/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/nodejs/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/nodejs/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/nodejs/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/nodejs/node/contents/{+path}","compare_url":"https://api.github.com/repos/nodejs/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nodejs/node/merges","archive_url":"https://api.github.com/repos/nodejs/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nodejs/node/downloads","issues_url":"https://api.github.com/repos/nodejs/node/issues{/number}","pulls_url":"https://api.github.com/repos/nodejs/node/pulls{/number}","milestones_url":"https://api.github.com/repos/nodejs/node/milestones{/number}","notifications_url":"https://api.github.com/repos/nodejs/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nodejs/node/labels{/name}","releases_url":"https://api.github.com/repos/nodejs/node/releases{/id}","created_at":"2014-11-26T19:57:11Z","updated_at":"2015-10-07T20:09:43Z","pushed_at":"2015-10-07T20:10:52Z","git_url":"git://github.com/nodejs/node.git","ssh_url":"git@github.com:nodejs/node.git","clone_url":"https://github.com/nodejs/node.git","svn_url":"https://github.com/nodejs/node","homepage":"https://nodejs.org","size":365348,"stargazers_count":15887,"watchers_count":15887,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1483,"mirror_url":null,"open_issues_count":494,"forks":1483,"open_issues":494,"watchers":15887,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nodejs/node/pulls/3243"},"html":{"href":"https://github.com/nodejs/node/pull/3243"},"issue":{"href":"https://api.github.com/repos/nodejs/node/issues/3243"},"comments":{"href":"https://api.github.com/repos/nodejs/node/issues/3243/comments"},"review_comments":{"href":"https://api.github.com/repos/nodejs/node/pulls/3243/comments"},"review_comment":{"href":"https://api.github.com/repos/nodejs/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nodejs/node/pulls/3243/commits"},"statuses":{"href":"https://api.github.com/repos/nodejs/node/statuses/c511b4a24ac36cc1703ecce2be172dab0a24077a"}}}}