{"action":"created","comment":{"url":"https://api.github.com/repos/cucumber/cucumber-js/pulls/comments/41801683","id":41801683,"diff_hunk":"@@ -106,19 +106,30 @@ function StepDefinition(pattern, options, code) {\n \n       Cucumber.Util.Exception.registerUncaughtExceptionHandler(handleException, stepDomain);\n \n+      var validCodeLengths = self.validCodeLengths(parameters);\n+      if (validCodeLengths.indexOf(code.length) === -1) {\n+        var error = 'definition has ' + code.length + ' arguments' +\n+          ', should have ' + validCodeLengths.join(' or ');\n+        return codeCallback(error);\n+      }\n+\n+      initializeTimeout();\n+\n+      var result;\n       try {\n-        var result = code.apply(world, parameters);\n-        var callbackOmitted = code.length < parameters.length;\n-        if (result && typeof result.then === 'function') {\n-          result.then(onPromiseFulfilled, onPromiseRejected);\n-          initializeTimeout();\n-        } else if (callbackOmitted) {\n-          codeCallback();\n-        } else {\n-          initializeTimeout();\n-        }\n+        result = code.apply(world, parameters);\n       } catch (exception) {\n-        handleException(exception);\n+        return handleException(exception);\n+      }\n+\n+      var callbackInterface = code.length === parameters.length;\n+      var promiseInterface = result && typeof result.then === 'function';\n+      if (callbackInterface && promiseInterface) {\n+        codeCallback('definition takes a callback and returns a promise');","path":"lib/cucumber/support_code/step_definition.js","position":34,"original_position":34,"commit_id":"a0b1ad9bdf58a02db1213510291502461ccc4db3","original_commit_id":"a0b1ad9bdf58a02db1213510291502461ccc4db3","user":{"login":"jbpros","id":52343,"avatar_url":"https://avatars.githubusercontent.com/u/52343?v=3","gravatar_id":"","url":"https://api.github.com/users/jbpros","html_url":"https://github.com/jbpros","followers_url":"https://api.github.com/users/jbpros/followers","following_url":"https://api.github.com/users/jbpros/following{/other_user}","gists_url":"https://api.github.com/users/jbpros/gists{/gist_id}","starred_url":"https://api.github.com/users/jbpros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbpros/subscriptions","organizations_url":"https://api.github.com/users/jbpros/orgs","repos_url":"https://api.github.com/users/jbpros/repos","events_url":"https://api.github.com/users/jbpros/events{/privacy}","received_events_url":"https://api.github.com/users/jbpros/received_events","type":"User","site_admin":false},"body":"Same comments: an Error instance and \"step definition\".","created_at":"2015-10-12T21:10:17Z","updated_at":"2015-10-12T21:10:17Z","html_url":"https://github.com/cucumber/cucumber-js/pull/428#discussion_r41801683","pull_request_url":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428","_links":{"self":{"href":"https://api.github.com/repos/cucumber/cucumber-js/pulls/comments/41801683"},"html":{"href":"https://github.com/cucumber/cucumber-js/pull/428#discussion_r41801683"},"pull_request":{"href":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428"}}},"pull_request":{"url":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428","id":47443363,"html_url":"https://github.com/cucumber/cucumber-js/pull/428","diff_url":"https://github.com/cucumber/cucumber-js/pull/428.diff","patch_url":"https://github.com/cucumber/cucumber-js/pull/428.patch","issue_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/428","number":428,"state":"open","locked":false,"title":"add strict function length checking to step definitions","user":{"login":"charlierudolph","id":1676758,"avatar_url":"https://avatars.githubusercontent.com/u/1676758?v=3","gravatar_id":"","url":"https://api.github.com/users/charlierudolph","html_url":"https://github.com/charlierudolph","followers_url":"https://api.github.com/users/charlierudolph/followers","following_url":"https://api.github.com/users/charlierudolph/following{/other_user}","gists_url":"https://api.github.com/users/charlierudolph/gists{/gist_id}","starred_url":"https://api.github.com/users/charlierudolph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charlierudolph/subscriptions","organizations_url":"https://api.github.com/users/charlierudolph/orgs","repos_url":"https://api.github.com/users/charlierudolph/repos","events_url":"https://api.github.com/users/charlierudolph/events{/privacy}","received_events_url":"https://api.github.com/users/charlierudolph/received_events","type":"User","site_admin":false},"body":"@jbpros \r\n\r\nresolves #367","created_at":"2015-10-12T17:12:28Z","updated_at":"2015-10-12T21:10:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f641cb2a84df0b354586105778468eec8272e2d6","assignee":null,"milestone":{"url":"https://api.github.com/repos/cucumber/cucumber-js/milestones/7","html_url":"https://github.com/cucumber/cucumber-js/milestones/1.0%20release","labels_url":"https://api.github.com/repos/cucumber/cucumber-js/milestones/7/labels","id":1348622,"number":7,"title":"1.0 release","description":"Cucumber.js has caught up with the important features of Cucumber-ruby.","creator":{"login":"jbpros","id":52343,"avatar_url":"https://avatars.githubusercontent.com/u/52343?v=3","gravatar_id":"","url":"https://api.github.com/users/jbpros","html_url":"https://github.com/jbpros","followers_url":"https://api.github.com/users/jbpros/followers","following_url":"https://api.github.com/users/jbpros/following{/other_user}","gists_url":"https://api.github.com/users/jbpros/gists{/gist_id}","starred_url":"https://api.github.com/users/jbpros/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbpros/subscriptions","organizations_url":"https://api.github.com/users/jbpros/orgs","repos_url":"https://api.github.com/users/jbpros/repos","events_url":"https://api.github.com/users/jbpros/events{/privacy}","received_events_url":"https://api.github.com/users/jbpros/received_events","type":"User","site_admin":false},"open_issues":19,"closed_issues":3,"state":"open","created_at":"2015-10-10T20:25:26Z","updated_at":"2015-10-12T20:57:58Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428/commits","review_comments_url":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428/comments","review_comment_url":"https://api.github.com/repos/cucumber/cucumber-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/428/comments","statuses_url":"https://api.github.com/repos/cucumber/cucumber-js/statuses/a0b1ad9bdf58a02db1213510291502461ccc4db3","head":{"label":"cucumber:cr-strictStepLength","ref":"cr-strictStepLength","sha":"a0b1ad9bdf58a02db1213510291502461ccc4db3","user":{"login":"cucumber","id":320565,"avatar_url":"https://avatars.githubusercontent.com/u/320565?v=3","gravatar_id":"","url":"https://api.github.com/users/cucumber","html_url":"https://github.com/cucumber","followers_url":"https://api.github.com/users/cucumber/followers","following_url":"https://api.github.com/users/cucumber/following{/other_user}","gists_url":"https://api.github.com/users/cucumber/gists{/gist_id}","starred_url":"https://api.github.com/users/cucumber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cucumber/subscriptions","organizations_url":"https://api.github.com/users/cucumber/orgs","repos_url":"https://api.github.com/users/cucumber/repos","events_url":"https://api.github.com/users/cucumber/events{/privacy}","received_events_url":"https://api.github.com/users/cucumber/received_events","type":"Organization","site_admin":false},"repo":{"id":1811965,"name":"cucumber-js","full_name":"cucumber/cucumber-js","owner":{"login":"cucumber","id":320565,"avatar_url":"https://avatars.githubusercontent.com/u/320565?v=3","gravatar_id":"","url":"https://api.github.com/users/cucumber","html_url":"https://github.com/cucumber","followers_url":"https://api.github.com/users/cucumber/followers","following_url":"https://api.github.com/users/cucumber/following{/other_user}","gists_url":"https://api.github.com/users/cucumber/gists{/gist_id}","starred_url":"https://api.github.com/users/cucumber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cucumber/subscriptions","organizations_url":"https://api.github.com/users/cucumber/orgs","repos_url":"https://api.github.com/users/cucumber/repos","events_url":"https://api.github.com/users/cucumber/events{/privacy}","received_events_url":"https://api.github.com/users/cucumber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cucumber/cucumber-js","description":"Cucumber for JavaScript","fork":false,"url":"https://api.github.com/repos/cucumber/cucumber-js","forks_url":"https://api.github.com/repos/cucumber/cucumber-js/forks","keys_url":"https://api.github.com/repos/cucumber/cucumber-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cucumber/cucumber-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cucumber/cucumber-js/teams","hooks_url":"https://api.github.com/repos/cucumber/cucumber-js/hooks","issue_events_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/events{/number}","events_url":"https://api.github.com/repos/cucumber/cucumber-js/events","assignees_url":"https://api.github.com/repos/cucumber/cucumber-js/assignees{/user}","branches_url":"https://api.github.com/repos/cucumber/cucumber-js/branches{/branch}","tags_url":"https://api.github.com/repos/cucumber/cucumber-js/tags","blobs_url":"https://api.github.com/repos/cucumber/cucumber-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cucumber/cucumber-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cucumber/cucumber-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/cucumber/cucumber-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cucumber/cucumber-js/statuses/{sha}","languages_url":"https://api.github.com/repos/cucumber/cucumber-js/languages","stargazers_url":"https://api.github.com/repos/cucumber/cucumber-js/stargazers","contributors_url":"https://api.github.com/repos/cucumber/cucumber-js/contributors","subscribers_url":"https://api.github.com/repos/cucumber/cucumber-js/subscribers","subscription_url":"https://api.github.com/repos/cucumber/cucumber-js/subscription","commits_url":"https://api.github.com/repos/cucumber/cucumber-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/cucumber/cucumber-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/cucumber/cucumber-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/cucumber/cucumber-js/contents/{+path}","compare_url":"https://api.github.com/repos/cucumber/cucumber-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cucumber/cucumber-js/merges","archive_url":"https://api.github.com/repos/cucumber/cucumber-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cucumber/cucumber-js/downloads","issues_url":"https://api.github.com/repos/cucumber/cucumber-js/issues{/number}","pulls_url":"https://api.github.com/repos/cucumber/cucumber-js/pulls{/number}","milestones_url":"https://api.github.com/repos/cucumber/cucumber-js/milestones{/number}","notifications_url":"https://api.github.com/repos/cucumber/cucumber-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cucumber/cucumber-js/labels{/name}","releases_url":"https://api.github.com/repos/cucumber/cucumber-js/releases{/id}","created_at":"2011-05-27T21:27:17Z","updated_at":"2015-10-12T17:17:27Z","pushed_at":"2015-10-12T17:13:44Z","git_url":"git://github.com/cucumber/cucumber-js.git","ssh_url":"git@github.com:cucumber/cucumber-js.git","clone_url":"https://github.com/cucumber/cucumber-js.git","svn_url":"https://github.com/cucumber/cucumber-js","homepage":"https://cucumber.io/docs/reference/javascript","size":10079,"stargazers_count":1688,"watchers_count":1688,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":288,"mirror_url":null,"open_issues_count":39,"forks":288,"open_issues":39,"watchers":1688,"default_branch":"master"}},"base":{"label":"cucumber:master","ref":"master","sha":"9959ca9fd9f8c64f0b5133f9bb241da9b854e570","user":{"login":"cucumber","id":320565,"avatar_url":"https://avatars.githubusercontent.com/u/320565?v=3","gravatar_id":"","url":"https://api.github.com/users/cucumber","html_url":"https://github.com/cucumber","followers_url":"https://api.github.com/users/cucumber/followers","following_url":"https://api.github.com/users/cucumber/following{/other_user}","gists_url":"https://api.github.com/users/cucumber/gists{/gist_id}","starred_url":"https://api.github.com/users/cucumber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cucumber/subscriptions","organizations_url":"https://api.github.com/users/cucumber/orgs","repos_url":"https://api.github.com/users/cucumber/repos","events_url":"https://api.github.com/users/cucumber/events{/privacy}","received_events_url":"https://api.github.com/users/cucumber/received_events","type":"Organization","site_admin":false},"repo":{"id":1811965,"name":"cucumber-js","full_name":"cucumber/cucumber-js","owner":{"login":"cucumber","id":320565,"avatar_url":"https://avatars.githubusercontent.com/u/320565?v=3","gravatar_id":"","url":"https://api.github.com/users/cucumber","html_url":"https://github.com/cucumber","followers_url":"https://api.github.com/users/cucumber/followers","following_url":"https://api.github.com/users/cucumber/following{/other_user}","gists_url":"https://api.github.com/users/cucumber/gists{/gist_id}","starred_url":"https://api.github.com/users/cucumber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cucumber/subscriptions","organizations_url":"https://api.github.com/users/cucumber/orgs","repos_url":"https://api.github.com/users/cucumber/repos","events_url":"https://api.github.com/users/cucumber/events{/privacy}","received_events_url":"https://api.github.com/users/cucumber/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cucumber/cucumber-js","description":"Cucumber for JavaScript","fork":false,"url":"https://api.github.com/repos/cucumber/cucumber-js","forks_url":"https://api.github.com/repos/cucumber/cucumber-js/forks","keys_url":"https://api.github.com/repos/cucumber/cucumber-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cucumber/cucumber-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cucumber/cucumber-js/teams","hooks_url":"https://api.github.com/repos/cucumber/cucumber-js/hooks","issue_events_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/events{/number}","events_url":"https://api.github.com/repos/cucumber/cucumber-js/events","assignees_url":"https://api.github.com/repos/cucumber/cucumber-js/assignees{/user}","branches_url":"https://api.github.com/repos/cucumber/cucumber-js/branches{/branch}","tags_url":"https://api.github.com/repos/cucumber/cucumber-js/tags","blobs_url":"https://api.github.com/repos/cucumber/cucumber-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cucumber/cucumber-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cucumber/cucumber-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/cucumber/cucumber-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cucumber/cucumber-js/statuses/{sha}","languages_url":"https://api.github.com/repos/cucumber/cucumber-js/languages","stargazers_url":"https://api.github.com/repos/cucumber/cucumber-js/stargazers","contributors_url":"https://api.github.com/repos/cucumber/cucumber-js/contributors","subscribers_url":"https://api.github.com/repos/cucumber/cucumber-js/subscribers","subscription_url":"https://api.github.com/repos/cucumber/cucumber-js/subscription","commits_url":"https://api.github.com/repos/cucumber/cucumber-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/cucumber/cucumber-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/cucumber/cucumber-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/cucumber/cucumber-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/cucumber/cucumber-js/contents/{+path}","compare_url":"https://api.github.com/repos/cucumber/cucumber-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cucumber/cucumber-js/merges","archive_url":"https://api.github.com/repos/cucumber/cucumber-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cucumber/cucumber-js/downloads","issues_url":"https://api.github.com/repos/cucumber/cucumber-js/issues{/number}","pulls_url":"https://api.github.com/repos/cucumber/cucumber-js/pulls{/number}","milestones_url":"https://api.github.com/repos/cucumber/cucumber-js/milestones{/number}","notifications_url":"https://api.github.com/repos/cucumber/cucumber-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cucumber/cucumber-js/labels{/name}","releases_url":"https://api.github.com/repos/cucumber/cucumber-js/releases{/id}","created_at":"2011-05-27T21:27:17Z","updated_at":"2015-10-12T17:17:27Z","pushed_at":"2015-10-12T17:13:44Z","git_url":"git://github.com/cucumber/cucumber-js.git","ssh_url":"git@github.com:cucumber/cucumber-js.git","clone_url":"https://github.com/cucumber/cucumber-js.git","svn_url":"https://github.com/cucumber/cucumber-js","homepage":"https://cucumber.io/docs/reference/javascript","size":10079,"stargazers_count":1688,"watchers_count":1688,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":288,"mirror_url":null,"open_issues_count":39,"forks":288,"open_issues":39,"watchers":1688,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428"},"html":{"href":"https://github.com/cucumber/cucumber-js/pull/428"},"issue":{"href":"https://api.github.com/repos/cucumber/cucumber-js/issues/428"},"comments":{"href":"https://api.github.com/repos/cucumber/cucumber-js/issues/428/comments"},"review_comments":{"href":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428/comments"},"review_comment":{"href":"https://api.github.com/repos/cucumber/cucumber-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cucumber/cucumber-js/pulls/428/commits"},"statuses":{"href":"https://api.github.com/repos/cucumber/cucumber-js/statuses/a0b1ad9bdf58a02db1213510291502461ccc4db3"}}}}