Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The error message displayed when compiling a template, doesn't contain location / file information #318

Open
kozak opened this issue Dec 2, 2015 · 12 comments

Comments

@kozak
Copy link

kozak commented Dec 2, 2015

I had an error in a handlebars template (there is a href="#" and also a binding to href):

{{#link-to "staff" tagName="li" }}
    <a href="#"  {{bind-attr href="view.href"}}>Test </a>
{{/link-to}}

The error I got, didn't include the file information that is normally included in ember build
This is what was displayed:

Error: Assertion Failed: You cannot set `href` manually and via `{{bind-attr}}` helper on the same element.
  at new Error (native)
  at Error.EmberError (adminr/bower_components/ember/ember-template-compiler.js:4064:21)
  at Object._emberMetalCore.default.assert (adminr/bower_components/ember/ember-template-compiler.js:169:13)
  at assertAttrNameIsUnused (adminr/bower_components/ember/ember-template-compiler.js:11766:38)
  at TransformBindAttrToAttributes.assignAttrs (adminr/bower_components/ember/ember-template-compiler.js:11662:7)
  at adminr/bower_components/ember/ember-template-compiler.js:11646:20
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18302:7)
  at visitors.Program (adminr/bower_components/ember/ember-template-compiler.js:18312:16)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.BlockStatement (adminr/bower_components/ember/ember-template-compiler.js:18323:14)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.Program (adminr/bower_components/ember/ember-template-compiler.js:18312:16)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.BlockStatement (adminr/bower_components/ember/ember-template-compiler.js:18323:14)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.ElementNode (adminr/bower_components/ember/ember-template-compiler.js:18318:16)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.ElementNode (adminr/bower_components/ember/ember-template-compiler.js:18318:16)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.Program (adminr/bower_components/ember/ember-template-compiler.js:18312:16)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.BlockStatement (adminr/bower_components/ember/ember-template-compiler.js:18323:14)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at visitors.Program (adminr/bower_components/ember/ember-template-compiler.js:18312:16)
  at Walker.children (adminr/bower_components/ember/ember-template-compiler.js:18335:7)
  at Walker.visit (adminr/bower_components/ember/ember-template-compiler.js:18303:12)
  at TransformBindAttrToAttributes_transform [as transform] (adminr/bower_components/ember/ember-template-compiler.js:11639:12)
  at Object.preprocess (adminr/bower_components/ember/ember-template-compiler.js:17693:27)
  at compileSpec (adminr/bower_components/ember/ember-template-compiler.js:12791:37)
  at Object.exports.default [as precompile] (adminr/bower_components/ember/ember-template-compiler.js:12705:12)
  at Object.module.exports.template (adminr/node_modules/ember-cli-htmlbars/utils.js:29:40)
  at TemplateCompiler.processString (adminr/node_modules/ember-cli-htmlbars/index.js:68:36)
  at adminr/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/lib/strategies/persistent.js:35:42
  at lib$rsvp$$internal$$tryCatch (adminr/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/node_modules/rsvp/dist/rsvp.js:493:16)
  at lib$rsvp$$internal$$invokeCallback (adminr/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/node_modules/rsvp/dist/rsvp.js:505:17)
  at lib$rsvp$$internal$$publish (adminr/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/node_modules/rsvp/dist/rsvp.js:476:11)
  at lib$rsvp$asap$$flush (adminr/node_modules/ember-cli-htmlbars/node_modules/broccoli-persistent-filter/node_modules/rsvp/dist/rsvp.js:1198:9)
  at process._tickCallback (node.js:355:11)

When I run ember build I get a huge stack trace (which also includes deprecation information) and the file name:

Build failed.
File: adminr/templates/application.handlebars
Assertion Failed: You cannot set `href` manually and via `{{bind-attr}}` helper on the same element.
@seanpdoyle
Copy link
Contributor

Thanks for opening this issue and bringing this to our attention!

This behavior is odd. The gem doesn't do anything with the ember-cli generated error / stack trace.

The way we handle inter process communication between rails s and ember b --watch is by depending on EmberCLI to write build errors to STDERR, which we redirect to an error file that Rails is watching.

Outside of that, we don't have any logic around including / excluding error messages or stack traces.

TL;DR:

What version of Ember CLI are you using?

What version of the gem are you using?

What version of the addon are you using?

On the surface, this sounds like a bug in the way EmberCLI writes errors.

@kozak
Copy link
Author

kozak commented Dec 2, 2015

Thanks for a speedy reply, sorry for not including this information in the first place:
package.json:
ember-cli: 1.13.13
ember-cli-rails-addon: "^0.5.2"

gem: most recent version from github, from Gemfile.lock

GIT
  remote: git@github.com:thoughtbot/ember-cli-rails.git
  revision: 7badc2581e0158bb8017cf5a24a39ea8d50b77df
  specs:
    ember-cli-rails (0.5.6)
      cocaine (~> 0.5.0)
      non-stupid-digest-assets (~> 1.0.0)
      railties (>= 3.2, < 5)
      sprockets (>= 2.0)

When doing:

%node_modules/ember-cli/bin/ember b app/app.js 2>errors.txt
version: 1.13.13
Build failed.

the generated errors.txt includes the file information, here is the output:
errors.txt

@seanpdoyle
Copy link
Contributor

@kozak would you mind pulling down #324 and seeing if that corrects this issue?

@kozak
Copy link
Author

kozak commented Dec 4, 2015

Bad news: Unfortunately, it doesn't.
Good news: it appears that Ember creates its own tmp/error.txt file that overwrites the one Ember cli rails is creating from stderr redirection. If I change the error file name here https://github.com/thoughtbot/ember-cli-rails/blob/master/lib/ember_cli/path_set.rb#L75 to be something different than error.txt the whole information is preserved in the log.

This also includes deprecations, so the first backtrace will not necessary be the actual ERROR.
I am working on a Pull request.

@kozak
Copy link
Author

kozak commented Dec 4, 2015

@seanpdoyle How do you want to approach filtering out deprecations from the error file ?

  • We could ask ember-cli to provide a flag to ember build to exclude deprecations (unless one is already present )
  • We could parse the error log by hand, but this would make it very fragile

seanpdoyle added a commit to rondale-sc/ember-cli-rails-addon that referenced this issue Dec 8, 2015
Related to [tricknotes/ember-cli-rails#318][#318].

The `ember-cli-rails` gem redirects the `ember build --watch` process'
`STDERR` to the same file the addon previously wrote two.

These two processes would contend over writing to the file, and
flip-flop, clobbering the others' output.

To correct this, we'll defer error logging to the gem (and ultimately,
`ember-cli`'s writing correctly to `STDERR`).

[#318]: tricknotes/ember-cli-rails#318
@seanpdoyle
Copy link
Contributor

Unfortunately, tmp/error.txt isn't an EmberCLI generated file. The file is generated by the ember-cli-rails-addon addon.

When the gem executes the ember build --watch command, the addon's error monitoring gets clobbered by redirecting STDERR to tmp/error.txt (and vice versa).

To correct this, we can change how the addon behaves.

Unfortunately, this fix is blocked by EmberCLI writing DEPRECATION warnings to STDERR.

Once a fix for that improper behavior lands, we can merge rondale-sc/ember-cli-rails-addon#24

@seanpdoyle
Copy link
Contributor

@kozak bad news: there isn't a good approach to prevent writing DEPRECATION warnings to STDERR.

good news is that @rwjblue has written https://github.com/rwjblue/ember-cli-template-lint, which delays throwing deprecation warnings, pushing them out of build tools and into the browser.

Would you mind adding that addon in combination with rondale-sc/ember-cli-rails-addon#24?

If that works for you, I could merge and release, documenting the new dependency.

@kayakyakr
Copy link

Tangentially related, I received:

[BABEL] Note: The code generator has deoptimised the styling of "/home/templates..." as it exceeds the max of "100KB".

Which is a warning of a stupidly long template, but causes the rails server to throw an error even though the build was technically successful. This is with rondale-sc/ember-cli-rails-addon#24

@kozak
Copy link
Author

kozak commented Dec 9, 2015

@seanpdoyle Sorry for getting back so late. Your suggested setup works fine and displays the correct error message!

@seanpdoyle
Copy link
Contributor

@kayakyakr addressed in babel/babel#3156

seanpdoyle added a commit to rondale-sc/ember-cli-rails-addon that referenced this issue Dec 11, 2015
Related to [tricknotes/ember-cli-rails#318][#318].

The `ember-cli-rails` gem redirects the `ember build --watch` process'
`STDERR` to the same file the addon previously wrote two.

These two processes would contend over writing to the file, and
flip-flop, clobbering the others' output.

To correct this, we'll defer error logging to the gem (and ultimately,
`ember-cli`'s writing correctly to `STDERR`).

[#318]: tricknotes/ember-cli-rails#318
@seanpdoyle
Copy link
Contributor

@kayakyakr according to to maintainer of Babel:

This is an error though. You shouldn't be passing such large files to the code generator as it's not currently suited for it. There's no stack trace because it's useless as the call stack depth is already too deep to show any useful debugging information.

babel/babel#3156 (comment)

@kayakyakr
Copy link

I've stopped receiving the error, though, so I can't dig deeper right now...

The worst thing is that it's coming from a handlebars template that's around 10k in size. A 250 line, 8000 character template explodes into a 99,000 character js file. Yikes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants