coffeecup dependency makes coffeescript line numbers dissappear #94

Closed
williamcoates opened this Issue Oct 15, 2013 · 9 comments

Projects

None yet

2 participants

@williamcoates

In coffeescript 1.6.3 you now get nice stacktraces with the coffeescript line numbers, e.g:

test.coffee:4:1, <js>:2:3

But as soon as I require zappajs I lose this ability, the same exception now shows only this:

test.coffee:2:3

For some reason this is due to coffeecup as instead of the coffee-script used being something like:

/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19

Its now

/Users/xxx/projects/xxxx/node_modules/zappajs/node_modules/coffeecup/node_modules/coffee-script/lib/coffee-script/coffee-script.js:182:19

If i remove references to coffeecup from zappajs, then I get my line numbers back.

Could we make coffeecup optional? This has wasted me many hours of frustration, as it makes debugging a pain again.

@williamcoates

Well removing coffeecup only goes some way in improving things. Still sometimes I dont get the coffeescript lines, no idea why ...

@shimaore
ZappaJS member

I would expect client and coffeecup code to lose its mappings (the code is wrapped and the original lines are lost in both cases); server-side code however should keep its line numbers. I've never tested it though, so I'll have to check.

@williamcoates

It was server side code I was writing, so seems to be some problem there.

@shimaore
ZappaJS member

OK, for starters, let's test something simple such as:

# main.coffee
require('zappajs') ->
  @get '/': ->
    a.foo = true

  @include 'included.coffee'

# included.coffee
@include = ->

  @get '/u': ->
    a.bar = true

In that case I get proper report on both 'GET /' and 'GET /u'.

@shimaore
ZappaJS member

If I replace main.coffee and add a view:

# main.coffee
require('zappajs') ->
  @get '/': ->
    a.foo = true

  @get '/c': ->
    @render 'foo'

  @view 'foo': ->
    html ->
      body ->
        div 'hello'

  @include 'u.coffee'

I get HTML when I GET /c and proper errors as previously for the other ones. (This time we're using coffeecup for the render.)

@shimaore
ZappaJS member

@williamcoates any chance to get more details on the kind of code you were having issues with?

@williamcoates

So the code I can reproduce it is pretty simple.

app/app.coffee:

zappa.run port, {disable_io: true}, ->
  @include '../config/server'

In config/server.coffee:

@include = ->
  boom

=>

ReferenceError: boom is not defined
  at Object.include (/Users/xxxx/projects/xxx/config/server.coffee:3:5)
@williamcoates williamcoates reopened this Oct 15, 2013
@shimaore
ZappaJS member

Thank you for the example. I can't reproduce the issue, though:

$ cat a/b/t.coffee 
zappa = require('zappajs')
port = 3000
zappa.run port, disable_io:true, ->
  @include '../c/u'
# I tried with "../c/u" and "../c/u.coffee".
$ cat a/c/u.coffee 
@include = ->
  boom
$ coffee a/b/t.coffee 
ReferenceError: boom is not defined
  at Object.include (/..../a/c/u.coffee:3:3, <js>:3:12)

(This is with CoffeeScript 1.6.3.)

It looks there is indeed something that causes it to revert to an earllier coffee-script version. I'm not really sure how this can happen nor how to go at it.

Just a hunch: does the same thing happen if you do @include require '../config/server' ?

@shimaore
ZappaJS member

@williamcoates This is pretty old so I'm not holding my breath, but since Zappa 1.x now uses teacup instead of coffeecup this might work better.

@shimaore shimaore closed this Jan 11, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment