Will FP ever have a great Stack Trace story in JS?

Jason Kuhrt jasonkuhrt at me.com
Thu Sep 17 01:23:54 UTC 2015


For some reason the email I wrote was cut off. In practice the stack trace gets worse, my test was just too easy. The last stack trace was based around using compose from ramda. The stack trace result was:

```
Error: Invariant Violation: createClass(...): Class specification must implement a `render` method.
    at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15)
    at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46)

    at /Users/jasonkuhrt/code/test/node_modules/ramda/dist/ramda.js:384:35
    at f1 (/Users/jasonkuhrt/code/test/node_modules/ramda/dist/ramda.js:156:27)

    at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
```



> On Sep 16, 2015, at 9:19 PM, James Kyle <me at thejameskyle.com> wrote:
> 
> Okay, let's break this down. Your example stack trace is really not a bad story.
> 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method.
> >     at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15)
> >     at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46)
> > 
> >     at /Users/jasonkuhrt/code/test/component-factory.js:4:41
> > 
> >     at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
> >     at Module._compile (module.js:434:26)
> >     at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
> >     at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7)
> >     at Module.load (module.js:355:32)
> >     at Function.Module._load (module.js:310:12)
> >     at Function.Module.runMain (module.js:475:10)
> 
> 
> First off, you need to remove all the module loading-related stuff:
> 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method.
> >     at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15)
> >     at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46)
> > 
> >     at /Users/jasonkuhrt/code/test/component-factory.js:4:41
> > 
> >     at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
> 
> 
> Now, You're left with test code and the internal stack trace of React. Remove the React stuff and you have:
> 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method. 
> >     at /Users/jasonkuhrt/code/test/component-factory.js:4:41
> > 
> >     at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1)
> 
> 
> I'm assuming that 2nd item is just the test itself so let's kill that too.
> 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method. 
> >     at /Users/jasonkuhrt/code/test/component-factory.js:4:41
> 
> 
> So your error is around line 4 of `/code/test/component-factory.js`, and the error is that you created a React class without a render method.
> 
> I don't see what was bad about that, you certainly wouldn't want remove any of that stack trace as it's all real operations that might need debugging.
> 
> I also don't see what this has to do with your FP example of:
> 
> 
> > ```
> > let compose = (b, a) => (...as) => b(a(...as))
> > ```
> 
> 
> As that's clearly not the issue in your stack trace.
> 
> Also, if you want these stack traces to be more meaningful, you should be talking to the JavaScript engine implementor. In your case v8 (since you're using Node).
> 
> 
>> This email brought to you by the letters T, J, and K.
> 
> 
> On Wed, Sep 16, 2015 at 5:16 PM, Jason Kuhrt <jasonkuhrt at me.com <mailto:jasonkuhrt at me.com>> wrote:
> 
> For example, today, a stone from the bedrock of FP: 
> 
> > ``` 
> > let compose = (b, a) => (...as) => b(a(...as)) 
> > ``` 
> 
> will cause a JS Stack Trace to go from something useful (space around useful line) like: 
> 
> > ``` 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method. 
> 
> > at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15) 
> 
> > at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46) 
> 
> > 
> 
> > at componentFactory (/Users/jasonkuhrt/code/test/component-factory.js:1:36) 
> 
> > 
> 
> > at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1) 
> > at Module._compile (module.js:460:26) 
> > at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5) 
> > at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7) 
> > at Module.load (module.js:355:32) 
> > at Function.Module._load (module.js:310:12) 
> > at Function.Module.runMain (module.js:501:10) 
> 
> > ``` 
> 
> To something much less useful like this: 
> 
> > ``` 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method. 
> > at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15) 
> > at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46) 
> > 
> > at /Users/jasonkuhrt/code/test/component-factory.js:4:41 
> > 
> > at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1) 
> > at Module._compile (module.js:434:26) 
> > at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5) 
> > at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7) 
> > at Module.load (module.js:355:32) 
> > at Function.Module._load (module.js:310:12) 
> > at Function.Module.runMain (module.js:475:10) 
> 
> > ``` 
> 
> And ultimately being in a real-life scenario/library/etc. (e.g. Ramda compose) leading to something almost useless: 
> 
> > ``` 
> 
> > Error: Invariant Violation: createClass(...): Class specification must implement a `render` method. 
> > at invariant (/Users/jasonkuhrt/code/test/node_modules/react/lib/invariant.js:42:15) 
> > at ReactClass.createClass (/Users/jasonkuhrt/code/test/node_modules/react/lib/ReactClass.js:898:46) 
> > 
> > at /Users/jasonkuhrt/code/test/node_modules/ramda/dist/ramda.js:384:35 
> > at f1 (/Users/jasonkuhrt/code/test/node_modules/ramda/dist/ramda.js:156:27) 
> > 
> > at Object.<anonymous> (/Users/jasonkuhrt/code/test/test.js:4:1) 
> > at Module._compile (module.js:434:26) 
> > at normalLoader (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5) 
> > at Object.require.extensions.(anonymous function) [as .js] (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:216:7) 
> > at Module.load (module.js:355:32) 
> > at Function.Module._load (module.js:310:12) 
> 
> > ``` 
> _______________________________________________ 
> es-discuss mailing list 
> es-discuss at mozilla.org 
> https://mail.mozilla.org/listinfo/es-discuss 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150916/c7a1ef84/attachment-0001.html>


More information about the es-discuss mailing list