-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Hi! We are using this library as a dependency of redbox-react via error-stack-parser, and I noticed there’s a kind of Chome Error object that causes it to crash.
I started filing this in https://github.com/stacktracejs/stacktrace.js by mistake so here goes a nice template 😄 .
Expected Behavior
Given an error object with the following stack as reported by error.stack.toString()
:
ReferenceError: chilxdren is not defined
at new Layout (webpack:///./src/Layout.js?:25:5)
at eval (webpack:///../react-hot-loader/~/react-proxy/modules/createClassProxy.js?:90:24)
at instantiate (webpack:///../react-hot-loader/~/react-proxy/modules/createClassProxy.js?:98:9)
at Layout (eval at proxyClass (webpack:///../react-hot-loader/~/react-proxy/modules/createClassProxy.js?), <anonymous>:4:17)
at ReactCompositeComponentMixin.mountComponent (webpack:///./~/react/lib/ReactCompositeComponent.js?:170:18)
at wrapper [as mountComponent] (webpack:///./~/react/lib/ReactPerf.js?:66:21)
at Object.ReactReconciler.mountComponent (webpack:///./~/react/lib/ReactReconciler.js?:39:35)
at ReactCompositeComponentMixin.performInitialMount (webpack:///./~/react/lib/ReactCompositeComponent.js?:289:34)
at ReactCompositeComponentMixin.mountComponent (webpack:///./~/react/lib/ReactCompositeComponent.js?:237:21)
at wrapper [as mountComponent] (webpack:///./~/react/lib/ReactPerf.js?:66:21)
It should parse all lines correctly and should not crash.
Current Behavior
It crashes with TypeError: Line Number must be a Number
while handling this particular line:
at Layout (eval at proxyClass (webpack:///../react-hot-loader/~/react-proxy/modules/createClassProxy.js?), <anonymous>:4:17)
As you can see, it has multiple entries separated by comma—presumably because the error was caught and rethrown, although I haven’t looked at why closely. The first item doesn’t have the line number info for some reason, but stacktrace.js
assumes that it is always there. This makes it parse the location info incorrectly and throw later:
This is a very tricky one because I’m debugging a dev version of the project which involves compiling several libraries. If you trust me I’m not making this up, you can parse the stack string I documented above to reproduce the issue. 😄
Context
I noticed this working on React Hot Loader 3 that will rely on error boundaries in React to handle errors as you edit the code, fix them without reloading the app.
I noticed that in some cases the error box failed to appear, and tracked it down to this dependency.
Your Environment
- stackframe version: 0.3.1
- Browser Name and version: Chrome 49.0.2623.112 (64-bit)
- Operating System and version (desktop or mobile): OS X 10.11 (15A279b)
- Link to your project: https://github.com/KeywordBrain/redbox-react
Possible Solution
Be more resilient to parsing errors and check the line number for being a number during parsing, use 0
otherwise.