{"action":"created","issue":{"url":"https://api.github.com/repos/facebook/react/issues/5973","repository_url":"https://api.github.com/repos/facebook/react","labels_url":"https://api.github.com/repos/facebook/react/issues/5973/labels{/name}","comments_url":"https://api.github.com/repos/facebook/react/issues/5973/comments","events_url":"https://api.github.com/repos/facebook/react/issues/5973/events","html_url":"https://github.com/facebook/react/pull/5973","id":131067693,"number":5973,"title":"Fix #5941 - Provide a way to register a last-chance exception handler","user":{"login":"RandScullard","id":4718759,"avatar_url":"https://avatars.githubusercontent.com/u/4718759?v=3","gravatar_id":"","url":"https://api.github.com/users/RandScullard","html_url":"https://github.com/RandScullard","followers_url":"https://api.github.com/users/RandScullard/followers","following_url":"https://api.github.com/users/RandScullard/following{/other_user}","gists_url":"https://api.github.com/users/RandScullard/gists{/gist_id}","starred_url":"https://api.github.com/users/RandScullard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RandScullard/subscriptions","organizations_url":"https://api.github.com/users/RandScullard/orgs","repos_url":"https://api.github.com/users/RandScullard/repos","events_url":"https://api.github.com/users/RandScullard/events{/privacy}","received_events_url":"https://api.github.com/users/RandScullard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/facebook/react/labels/CLA%20Signed","name":"CLA Signed","color":"e7e7e7"},{"url":"https://api.github.com/repos/facebook/react/labels/GH%20Review:%20review-needed","name":"GH Review: review-needed","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-02-03T15:58:45Z","updated_at":"2016-02-04T14:56:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/facebook/react/pulls/5973","html_url":"https://github.com/facebook/react/pull/5973","diff_url":"https://github.com/facebook/react/pull/5973.diff","patch_url":"https://github.com/facebook/react/pull/5973.patch"},"body":"Add an onUnhandledError function to ReactDOM to allow registration of a callback for unhandled exceptions.\r\nCall the registered callback from the catch block of ReactEventListener.dispatchEvent.\r\nCall the production invokeGuardedCallback function from the dev version of ReactErrorUtils.invokeGuardedCallback."},"comment":{"url":"https://api.github.com/repos/facebook/react/issues/comments/179882232","html_url":"https://github.com/facebook/react/pull/5973#issuecomment-179882232","issue_url":"https://api.github.com/repos/facebook/react/issues/5973","id":179882232,"user":{"login":"jimfb","id":9595985,"avatar_url":"https://avatars.githubusercontent.com/u/9595985?v=3","gravatar_id":"","url":"https://api.github.com/users/jimfb","html_url":"https://github.com/jimfb","followers_url":"https://api.github.com/users/jimfb/followers","following_url":"https://api.github.com/users/jimfb/following{/other_user}","gists_url":"https://api.github.com/users/jimfb/gists{/gist_id}","starred_url":"https://api.github.com/users/jimfb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimfb/subscriptions","organizations_url":"https://api.github.com/users/jimfb/orgs","repos_url":"https://api.github.com/users/jimfb/repos","events_url":"https://api.github.com/users/jimfb/events{/privacy}","received_events_url":"https://api.github.com/users/jimfb/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T14:56:34Z","updated_at":"2016-02-04T14:56:34Z","body":"@RandScullard\r\n > It sounds like you have something in mind with your comment about polyfilling window.addEventListener -- can you give me more detail on how that could provide access to the Error object in window.onerror?\r\n\r\nBasically, hook into the event listener registration.  Users don't need to change the way they register for event listeners, but an error which is thrown from a React event handler would result in an a polyfilled call such that onError would have the thrown error even on legacy browsers.\r\n```\r\nwindow oldAddEventListener = window.addEventListener;\r\nwindow.addEventListener = function(type, listener, useCapture, wantsUntrusted) {\r\n  if(type === \"Error\") {\r\n    /* do something fancy here (your ReactDOM.onUnhandledException logic) */\r\n  }\r\n  else oldAddEventListener(type, listener, useCapture, wantsUntrusted);\r\n}\r\n```\r\nAlso, the custom fancy logic would need to properly register with `oldAddEventListener` to ensure non-react errors continued to work.\r\n\r\nIt's a little treacherous, but at least it wouldn't be an API change and is inline with the event smooting/polyfilling that we already do.  Not sure if we'd actually want to do this, but something like this is a potential option.\r\n\r\n > P.P.S. Is anybody looking into the problem with eslint? See the build failure on this PR.\r\n Hide all checks\r\n\r\nYeah, we're aware of the issue.  Paul is the best person to handle this, but he is currently in the process of moving 800+ miles away (all his stuff is packed into boxes), so we'll cut him some slack :).  In the mean time, we're just ignoring the lint error.  If someone else wants to take a stab at fixing the linter, I'm sure he'd appriciate the effort."}}