{"action":"created","comment":{"url":"https://api.github.com/repos/sindresorhus/got/pulls/comments/201312482","pull_request_review_id":135785166,"id":201312482,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTMxMjQ4Mg==","diff_hunk":"@@ -108,14 +108,31 @@ module.exports = (url, options) => {\n \t\t}\n \t}\n \n-\tif (!is.function(options.retries)) {\n-\t\tconst {retries} = options;\n+\toptions.gotRetries = {retry: 0, methods: [], statusCodes: []};\n+\tif (is.function(options.retries) || is.number(options.retries)) {\n+\t\toptions.gotRetries.retry = options.retries;\n+\t} else if (is.object(options.retries)) {\n+\t\toptions.gotRetries = {...options.gotRetries, ...options.retries};\n+\t}\n+\tdelete options.retries;\n+\n+\tif (!is.function(options.gotRetries.retry)) {\n+\t\tconst {retry} = options.gotRetries;\n \n-\t\toptions.retries = (iter, error) => {\n-\t\t\tif (iter > retries || !isRetryAllowed(error)) {\n+\t\toptions.gotRetries.retry = (iter, error) => {\n+\t\t\tif (iter > retry || (!isRetryAllowed(error) && !options.gotRetries.methods.includes(error.method) && !options.gotRetries.statusCodes.includes(error.statusCode))) {\n \t\t\t\treturn 0;\n \t\t\t}\n \n+\t\t\tif (error.statusCode === 413 && Reflect.has(error.headers, 'retry-after')) {\n+\t\t\t\tconst after = Number(error.headers['retry-after']);\n+\t\t\t\tif (is.number(after)) {\n+\t\t\t\t\treturn after * 1000;\n+\t\t\t\t}\n+\n+\t\t\t\treturn Math.max((new Date(error.headers['retry-after'])).getTime() - Date.now(), 0);","path":"source/normalize-arguments.js","position":30,"original_position":30,"commit_id":"ac503468d55e78daecca8abe658ca14d371ae88c","original_commit_id":"ac503468d55e78daecca8abe658ca14d371ae88c","user":{"login":"sindresorhus","id":170270,"node_id":"MDQ6VXNlcjE3MDI3MA==","avatar_url":"https://avatars1.githubusercontent.com/u/170270?v=4","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"body":"You can use `Date.parse(error.headers['retry-after'])` instead of `(new Date(error.headers['retry-after'])).getTime()`","created_at":"2018-07-10T11:50:10Z","updated_at":"2018-07-10T12:04:11Z","html_url":"https://github.com/sindresorhus/got/pull/508#discussion_r201312482","pull_request_url":"https://api.github.com/repos/sindresorhus/got/pulls/508","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/got/pulls/comments/201312482"},"html":{"href":"https://github.com/sindresorhus/got/pull/508#discussion_r201312482"},"pull_request":{"href":"https://api.github.com/repos/sindresorhus/got/pulls/508"}}},"pull_request":{"url":"https://api.github.com/repos/sindresorhus/got/pulls/508","id":200134992,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwMTM0OTky","html_url":"https://github.com/sindresorhus/got/pull/508","diff_url":"https://github.com/sindresorhus/got/pull/508.diff","patch_url":"https://github.com/sindresorhus/got/pull/508.patch","issue_url":"https://api.github.com/repos/sindresorhus/got/issues/508","number":508,"state":"open","locked":false,"title":"Custom retries","user":{"login":"szmarczak","id":36894700,"node_id":"MDQ6VXNlcjM2ODk0NzAw","avatar_url":"https://avatars0.githubusercontent.com/u/36894700?v=4","gravatar_id":"","url":"https://api.github.com/users/szmarczak","html_url":"https://github.com/szmarczak","followers_url":"https://api.github.com/users/szmarczak/followers","following_url":"https://api.github.com/users/szmarczak/following{/other_user}","gists_url":"https://api.github.com/users/szmarczak/gists{/gist_id}","starred_url":"https://api.github.com/users/szmarczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szmarczak/subscriptions","organizations_url":"https://api.github.com/users/szmarczak/orgs","repos_url":"https://api.github.com/users/szmarczak/repos","events_url":"https://api.github.com/users/szmarczak/events{/privacy}","received_events_url":"https://api.github.com/users/szmarczak/received_events","type":"User","site_admin":false},"body":"Closes #417 ","created_at":"2018-07-09T15:22:03Z","updated_at":"2018-07-10T12:04:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"82373c55d95240894687a8c67cf0436709ff2755","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sindresorhus/got/pulls/508/commits","review_comments_url":"https://api.github.com/repos/sindresorhus/got/pulls/508/comments","review_comment_url":"https://api.github.com/repos/sindresorhus/got/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sindresorhus/got/issues/508/comments","statuses_url":"https://api.github.com/repos/sindresorhus/got/statuses/ac503468d55e78daecca8abe658ca14d371ae88c","head":{"label":"szmarczak:retries-patch","ref":"retries-patch","sha":"ac503468d55e78daecca8abe658ca14d371ae88c","user":{"login":"szmarczak","id":36894700,"node_id":"MDQ6VXNlcjM2ODk0NzAw","avatar_url":"https://avatars0.githubusercontent.com/u/36894700?v=4","gravatar_id":"","url":"https://api.github.com/users/szmarczak","html_url":"https://github.com/szmarczak","followers_url":"https://api.github.com/users/szmarczak/followers","following_url":"https://api.github.com/users/szmarczak/following{/other_user}","gists_url":"https://api.github.com/users/szmarczak/gists{/gist_id}","starred_url":"https://api.github.com/users/szmarczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szmarczak/subscriptions","organizations_url":"https://api.github.com/users/szmarczak/orgs","repos_url":"https://api.github.com/users/szmarczak/repos","events_url":"https://api.github.com/users/szmarczak/events{/privacy}","received_events_url":"https://api.github.com/users/szmarczak/received_events","type":"User","site_admin":false},"repo":{"id":123169698,"node_id":"MDEwOlJlcG9zaXRvcnkxMjMxNjk2OTg=","name":"got","full_name":"szmarczak/got","owner":{"login":"szmarczak","id":36894700,"node_id":"MDQ6VXNlcjM2ODk0NzAw","avatar_url":"https://avatars0.githubusercontent.com/u/36894700?v=4","gravatar_id":"","url":"https://api.github.com/users/szmarczak","html_url":"https://github.com/szmarczak","followers_url":"https://api.github.com/users/szmarczak/followers","following_url":"https://api.github.com/users/szmarczak/following{/other_user}","gists_url":"https://api.github.com/users/szmarczak/gists{/gist_id}","starred_url":"https://api.github.com/users/szmarczak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/szmarczak/subscriptions","organizations_url":"https://api.github.com/users/szmarczak/orgs","repos_url":"https://api.github.com/users/szmarczak/repos","events_url":"https://api.github.com/users/szmarczak/events{/privacy}","received_events_url":"https://api.github.com/users/szmarczak/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/szmarczak/got","description":"Simplified HTTP requests","fork":true,"url":"https://api.github.com/repos/szmarczak/got","forks_url":"https://api.github.com/repos/szmarczak/got/forks","keys_url":"https://api.github.com/repos/szmarczak/got/keys{/key_id}","collaborators_url":"https://api.github.com/repos/szmarczak/got/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/szmarczak/got/teams","hooks_url":"https://api.github.com/repos/szmarczak/got/hooks","issue_events_url":"https://api.github.com/repos/szmarczak/got/issues/events{/number}","events_url":"https://api.github.com/repos/szmarczak/got/events","assignees_url":"https://api.github.com/repos/szmarczak/got/assignees{/user}","branches_url":"https://api.github.com/repos/szmarczak/got/branches{/branch}","tags_url":"https://api.github.com/repos/szmarczak/got/tags","blobs_url":"https://api.github.com/repos/szmarczak/got/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/szmarczak/got/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/szmarczak/got/git/refs{/sha}","trees_url":"https://api.github.com/repos/szmarczak/got/git/trees{/sha}","statuses_url":"https://api.github.com/repos/szmarczak/got/statuses/{sha}","languages_url":"https://api.github.com/repos/szmarczak/got/languages","stargazers_url":"https://api.github.com/repos/szmarczak/got/stargazers","contributors_url":"https://api.github.com/repos/szmarczak/got/contributors","subscribers_url":"https://api.github.com/repos/szmarczak/got/subscribers","subscription_url":"https://api.github.com/repos/szmarczak/got/subscription","commits_url":"https://api.github.com/repos/szmarczak/got/commits{/sha}","git_commits_url":"https://api.github.com/repos/szmarczak/got/git/commits{/sha}","comments_url":"https://api.github.com/repos/szmarczak/got/comments{/number}","issue_comment_url":"https://api.github.com/repos/szmarczak/got/issues/comments{/number}","contents_url":"https://api.github.com/repos/szmarczak/got/contents/{+path}","compare_url":"https://api.github.com/repos/szmarczak/got/compare/{base}...{head}","merges_url":"https://api.github.com/repos/szmarczak/got/merges","archive_url":"https://api.github.com/repos/szmarczak/got/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/szmarczak/got/downloads","issues_url":"https://api.github.com/repos/szmarczak/got/issues{/number}","pulls_url":"https://api.github.com/repos/szmarczak/got/pulls{/number}","milestones_url":"https://api.github.com/repos/szmarczak/got/milestones{/number}","notifications_url":"https://api.github.com/repos/szmarczak/got/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/szmarczak/got/labels{/name}","releases_url":"https://api.github.com/repos/szmarczak/got/releases{/id}","deployments_url":"https://api.github.com/repos/szmarczak/got/deployments","created_at":"2018-02-27T18:18:00Z","updated_at":"2018-07-07T03:52:11Z","pushed_at":"2018-07-10T11:49:46Z","git_url":"git://github.com/szmarczak/got.git","ssh_url":"git@github.com:szmarczak/got.git","clone_url":"https://github.com/szmarczak/got.git","svn_url":"https://github.com/szmarczak/got","homepage":"","size":1033,"stargazers_count":1,"watchers_count":1,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"sindresorhus:master","ref":"master","sha":"3eac42a5fd07059a1e284a671e1062cc0b363da4","user":{"login":"sindresorhus","id":170270,"node_id":"MDQ6VXNlcjE3MDI3MA==","avatar_url":"https://avatars1.githubusercontent.com/u/170270?v=4","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"repo":{"id":18193978,"node_id":"MDEwOlJlcG9zaXRvcnkxODE5Mzk3OA==","name":"got","full_name":"sindresorhus/got","owner":{"login":"sindresorhus","id":170270,"node_id":"MDQ6VXNlcjE3MDI3MA==","avatar_url":"https://avatars1.githubusercontent.com/u/170270?v=4","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sindresorhus/got","description":"Simplified HTTP requests","fork":false,"url":"https://api.github.com/repos/sindresorhus/got","forks_url":"https://api.github.com/repos/sindresorhus/got/forks","keys_url":"https://api.github.com/repos/sindresorhus/got/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sindresorhus/got/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sindresorhus/got/teams","hooks_url":"https://api.github.com/repos/sindresorhus/got/hooks","issue_events_url":"https://api.github.com/repos/sindresorhus/got/issues/events{/number}","events_url":"https://api.github.com/repos/sindresorhus/got/events","assignees_url":"https://api.github.com/repos/sindresorhus/got/assignees{/user}","branches_url":"https://api.github.com/repos/sindresorhus/got/branches{/branch}","tags_url":"https://api.github.com/repos/sindresorhus/got/tags","blobs_url":"https://api.github.com/repos/sindresorhus/got/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sindresorhus/got/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sindresorhus/got/git/refs{/sha}","trees_url":"https://api.github.com/repos/sindresorhus/got/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sindresorhus/got/statuses/{sha}","languages_url":"https://api.github.com/repos/sindresorhus/got/languages","stargazers_url":"https://api.github.com/repos/sindresorhus/got/stargazers","contributors_url":"https://api.github.com/repos/sindresorhus/got/contributors","subscribers_url":"https://api.github.com/repos/sindresorhus/got/subscribers","subscription_url":"https://api.github.com/repos/sindresorhus/got/subscription","commits_url":"https://api.github.com/repos/sindresorhus/got/commits{/sha}","git_commits_url":"https://api.github.com/repos/sindresorhus/got/git/commits{/sha}","comments_url":"https://api.github.com/repos/sindresorhus/got/comments{/number}","issue_comment_url":"https://api.github.com/repos/sindresorhus/got/issues/comments{/number}","contents_url":"https://api.github.com/repos/sindresorhus/got/contents/{+path}","compare_url":"https://api.github.com/repos/sindresorhus/got/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sindresorhus/got/merges","archive_url":"https://api.github.com/repos/sindresorhus/got/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sindresorhus/got/downloads","issues_url":"https://api.github.com/repos/sindresorhus/got/issues{/number}","pulls_url":"https://api.github.com/repos/sindresorhus/got/pulls{/number}","milestones_url":"https://api.github.com/repos/sindresorhus/got/milestones{/number}","notifications_url":"https://api.github.com/repos/sindresorhus/got/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sindresorhus/got/labels{/name}","releases_url":"https://api.github.com/repos/sindresorhus/got/releases{/id}","deployments_url":"https://api.github.com/repos/sindresorhus/got/deployments","created_at":"2014-03-27T22:40:49Z","updated_at":"2018-07-10T11:31:22Z","pushed_at":"2018-07-10T11:49:47Z","git_url":"git://github.com/sindresorhus/got.git","ssh_url":"git@github.com:sindresorhus/got.git","clone_url":"https://github.com/sindresorhus/got.git","svn_url":"https://github.com/sindresorhus/got","homepage":"","size":976,"stargazers_count":2767,"watchers_count":2767,"language":"JavaScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":180,"mirror_url":null,"archived":false,"open_issues_count":19,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":180,"open_issues":19,"watchers":2767,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/got/pulls/508"},"html":{"href":"https://github.com/sindresorhus/got/pull/508"},"issue":{"href":"https://api.github.com/repos/sindresorhus/got/issues/508"},"comments":{"href":"https://api.github.com/repos/sindresorhus/got/issues/508/comments"},"review_comments":{"href":"https://api.github.com/repos/sindresorhus/got/pulls/508/comments"},"review_comment":{"href":"https://api.github.com/repos/sindresorhus/got/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sindresorhus/got/pulls/508/commits"},"statuses":{"href":"https://api.github.com/repos/sindresorhus/got/statuses/ac503468d55e78daecca8abe658ca14d371ae88c"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"sindresorhus"}}