Amphtml: Improve amp-bind debuggability

Created on 30 Jan 2017  路  8Comments  路  Source: ampproject/amphtml

  • [x] Report syntax/expression errors through error.js#reportError.
  • [x] Add fine-level logging for state and component updates, etc.
  • [x] Output warning for undefined variables, improve error message specificity

Related to #6199.

/cc @kul3r4

High Priority Bug

Most helpful comment

Would be great to have a way to dump the global state in the console. We could then later wrap it in a Chrome DevTools Extension.

All 8 comments

Is this currently integrated with "element level" exceptions that highlight elements that have a problem. E.g. if an expression associated with them has an exception?

Hmm, not sure which exceptions you're referring to.

Currently, on page load:

  • user().error on expression parse failure or invalid binding
  • If dev mode, user().error when initial state != expression result

TODO:

  • If #log=4, dev().fine on data flow steps to aid in bug reporting

Ah, no it doesn't; added to list above. Thanks for the reference.

@choumx What is the solution for developer when debugging amp-bind variables?

Would be great to have a way to dump the global state in the console. We could then later wrap it in a Chrome DevTools Extension.

@kul3r4 You can create elements with [text] bindings to the expression you want to debug, e.g.

<p [text]="myState.foo + 123">Debug here</p>

I think that may be more convenient than repeatedly running "print expression" commands in dev console. Let me know if that doesn't work for you.

@cramforce Good idea, will track this in the next sprint.

I understand I can use [text] bindings but this requires to redeploy a new version of the page just for debugging. Interested in a way of dumping the global state in the console and use it in a Chrome DevTools Extension

Was this page helpful?
0 / 5 - 0 ratings

Related issues

torch2424 picture torch2424  路  3Comments

gmajoulet picture gmajoulet  路  3Comments

mrjoro picture mrjoro  路  3Comments

mkhatib picture mkhatib  路  3Comments

radiovisual picture radiovisual  路  3Comments