{"action":"opened","issue":{"url":"https://api.github.com/repos/jasmine/jasmine/issues/1349","repository_url":"https://api.github.com/repos/jasmine/jasmine","labels_url":"https://api.github.com/repos/jasmine/jasmine/issues/1349/labels{/name}","comments_url":"https://api.github.com/repos/jasmine/jasmine/issues/1349/comments","events_url":"https://api.github.com/repos/jasmine/jasmine/issues/1349/events","html_url":"https://github.com/jasmine/jasmine/issues/1349","id":227151389,"number":1349,"title":"Async errors are sometimes routed to many specs","user":{"login":"sgravrock","id":2879775,"avatar_url":"https://avatars1.githubusercontent.com/u/2879775?v=3","gravatar_id":"","url":"https://api.github.com/users/sgravrock","html_url":"https://github.com/sgravrock","followers_url":"https://api.github.com/users/sgravrock/followers","following_url":"https://api.github.com/users/sgravrock/following{/other_user}","gists_url":"https://api.github.com/users/sgravrock/gists{/gist_id}","starred_url":"https://api.github.com/users/sgravrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sgravrock/subscriptions","organizations_url":"https://api.github.com/users/sgravrock/orgs","repos_url":"https://api.github.com/users/sgravrock/repos","events_url":"https://api.github.com/users/sgravrock/events{/privacy}","received_events_url":"https://api.github.com/users/sgravrock/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-05-08T19:39:17Z","updated_at":"2017-05-08T19:39:17Z","closed_at":null,"body":"This looks like it might be similar to #1342 except that it only reproduces in Node as far as I can tell. When a spec causes an uncaught exception after telling Jasmine that it's done (in this case by returning from a synchronous spec), Jasmine will sometimes report the error on multiple unrelated specs.\r\n\r\nHere's the spec that causes it:\r\n\r\n```\r\n  it(\"fails in several different ways\", function(done) {\r\n    var env = new jasmineUnderTest.Env(),\r\n        reporter = jasmine.createSpyObj('fakeReporter', [\r\n          \"jasmineStarted\",\r\n          \"jasmineDone\",\r\n          \"suiteStarted\",\r\n          \"suiteDone\",\r\n          \"specStarted\",\r\n          \"specDone\"\r\n        ]);\r\n    env.randomizeTests(true);\r\n    env.seed('123456');\r\n\r\n    reporter.jasmineDone.and.callFake(function(doneArg) {\r\n      throw new Error('oops!');\r\n    });\r\n\r\n    env.addReporter(reporter);\r\n    env.execute();\r\n  });\r\n```\r\n\r\nBut it's at least somewhat dependent on random seed, what specs run after it, and moonphase so it's probably best to just grab the misrouted-errors branch https://github.com/sgravrock/jasmine/ and play with that. \r\n\r\nAnd here's output that shows several different behaviors, including 51 specs failing with the same error.\r\n\r\n```\r\nScript started on Mon May  8 12:19:41 2017\r\nbash-3.2$ grunt execSpecsInNode\r\nRunning \"execSpecsInNode\" task\r\nStarted\r\n....[ snipped page-widening dots]/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/GlobalErrors.js:8\r\n      handler.apply(null, Array.prototype.slice.call(arguments, 0));\r\n             ^\r\n\r\nTypeError: Cannot read property 'apply' of undefined\r\n  at process.onerror (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/GlobalErrors.js:8:14)\r\n  at emitOne (events.js:101:20)\r\n  at process.emit (events.js:188:7)\r\n  at process._fatalException (bootstrap_node.js:297:26)\r\n\r\nbash-3.2$ grunt execSpecsInNode\r\nRunning \"execSpecsInNode\" task\r\nStarted\r\n...[ snipped page-widening dots]\r\nFailures:\r\n1) Env integration fails in several different ways\r\n  Message:\r\n    Error: oops!\r\n  Stack:\r\n    Error: oops!\r\n      at Object.<anonymous> (/Users/pivotal/workspace/jasmine-stuff/jasmine/spec/core/integration/EnvSpec.js:1407:13)\r\n      at dispatch (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/ReportDispatcher.js:39:28)\r\n      at ReportDispatcher.jasmineDone (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/ReportDispatcher.js:10:11)\r\n      at Immediate.<anonymous> (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/Env.js:268:18)\r\n      at runCallback (timers.js:672:20)\r\n      at tryOnImmediate (timers.js:645:5)\r\n      at processImmediate [as _immediateCallback] (timers.js:617:5)\r\n    \r\n\r\n[... snipped another 49 specs that failed with the same erorr ...]\r\n\r\n51) Env integration suiteDone reporting reports when an async afterAll fails an expectation\r\n  Message:\r\n    Error: oops!\r\n  Stack:\r\n    Error: oops!\r\n      at Object.<anonymous> (/Users/pivotal/workspace/jasmine-stuff/jasmine/spec/core/integration/EnvSpec.js:1407:13)\r\n      at dispatch (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/ReportDispatcher.js:39:28)\r\n      at ReportDispatcher.jasmineDone (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/ReportDispatcher.js:10:11)\r\n      at Immediate.<anonymous> (/Users/pivotal/workspace/jasmine-stuff/jasmine/src/core/Env.js:268:18)\r\n      at runCallback (timers.js:672:20)\r\n      at tryOnImmediate (timers.js:645:5)\r\n      at processImmediate [as _immediateCallback] (timers.js:617:5)\r\n    \r\n\r\nRan 689 of 693 specs\r\n689 specs, 51 failures\r\nFinished in 0.931 seconds\r\n\r\nRandomized with seed 95427\r\nWarning: Task \"execSpecsInNode\" failed.\u0007 Use --force to continue.\r\n\r\nAborted due to warnings.\r\nbash-3.2$ grunt execSpecsInNode\r\nRunning \"execSpecsInNode\" task\r\nStarted\r\n..[ snipped page-widening dots]\r\n\r\n\r\nRan 689 of 693 specs\r\n689 specs, 0 failures\r\nFinished in 0.93 seconds\r\n\r\nRandomized with seed 28208\r\n\r\nDone.\r\nbash-3.2$ exit\r\n\r\nScript done on Mon May  8 12:19:54 2017\r\n```\r\n"}}
{"actor":{"display_login":"sgravrock"}}