You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Roger Binns <ro...@rogerbinns.com> on 2009/12/10 06:49:14 UTC
Debugging show/view/list/filter etc code
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Trying to debug this code (Javascript) is a royal pain. It is like being
back in the dark ages adding log() statements. I have resorted to running
my code separately directly under the 'js' interpreter but it isn't quite
the same environment. (Sometimes you can even get tracebacks. But you are
out of luck if you have an exception while handling an exception!) The wiki
is despairing for views and the situation is no better for
shows/lists/filters etc.
http://wiki.apache.org/couchdb/HTTP_view_API#Debugging_Views
Anyway I think it is relatively easy to make nice interactive debugging
possible as a feature of futon maybe with some server side help. My guess
is that you require Firebug in the client browser and then feed it a page of
Javascript that emulates the server environment. It would contain the
defined show/view/list/filter and just enough glue to work (eg fetch the
appropriate docs from the server, make emit and log send messages to Firebug
console). Then you just use the regular debugging functionality builtin to
Firebug.
It is also possible to extend this environment to help with compliance and
testing. For example it can emulate rereduce for views, shows with null
docs etc.
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAksgi9kACgkQmOOfHg372QT11QCbBZ8g7j/trfCoo52AFEiY0gY5
Wd8AoKinzQV8LC9izLlNyE6sy8fgYmTd
=R+Eg
-----END PGP SIGNATURE-----
Re: Debugging show/view/list/filter etc code
Posted by Roger Binns <ro...@rogerbinns.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Chris Anderson wrote:
>> I've been working on the query server JSON line protocol over the last
>> few days and have recently uncovered an as-yet-undiscovered trove of
>> much better error messages.
It certainly would be nice to have better error messages but that doesn't
really help with debugging. For example you can't single step, insert
breakpoints, examine objects etc.
> (apologies for the Short Circuit 2 reference...)
You need to more than apologise :-)
In any event your work is orthogonal to what I am talking about. Firebug is
already a great interactive Javascript debugger and comes with a user
interface so there is no need to reinvent the debugger side of things.
Assembling a representative page is also pretty easy in concept. Suck out
the relevant filter/view/show from the server and put in a few lines of glue
logic to grab the data they operate on. What I don't know is if the page
plus all glue logic has to be provided as a single entity from the server
(in which it involves more erlang hacking than I am prepared to do) or if
Javascript code running in the browser can incrementally build up the code
pieces and then initiate Firebug on them. If the latter is the case then it
would work as a great feature within or alongside futon.
Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkshX90ACgkQmOOfHg372QRLUgCdGHaEbl7zH04+66GB7xX2xD0V
uEMAoIFz5VmPzIjA28pxdjM4kwVmb5I3
=zhpi
-----END PGP SIGNATURE-----
Re: Debugging show/view/list/filter etc code
Posted by Chris Anderson <jc...@apache.org>.
On Wed, Dec 9, 2009 at 9:49 PM, Roger Binns <ro...@rogerbinns.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Trying to debug this code (Javascript) is a royal pain. It is like being
> back in the dark ages adding log() statements. I have resorted to running
> my code separately directly under the 'js' interpreter but it isn't quite
> the same environment. (Sometimes you can even get tracebacks. But you are
> out of luck if you have an exception while handling an exception!) The wiki
> is despairing for views and the situation is no better for
> shows/lists/filters etc.
>
I've been working on the query server JSON line protocol over the last
few days and have recently uncovered an as-yet-undiscovered trove of
much better error messages. I hope to have my coding done in the next
week or so, and the branch merged. For now you can follow along (and
help) here, although be warned that most JavaScript functionality
currently has it's guts hanging out like Johnny 5 after the bank
robbers beat him up. (apologies for the Short Circuit 2 reference...)
The branch: http://github.com/jchris/couchdb/tree/ddoc-qs
Chris
> http://wiki.apache.org/couchdb/HTTP_view_API#Debugging_Views
>
> Anyway I think it is relatively easy to make nice interactive debugging
> possible as a feature of futon maybe with some server side help. My guess
> is that you require Firebug in the client browser and then feed it a page of
> Javascript that emulates the server environment. It would contain the
> defined show/view/list/filter and just enough glue to work (eg fetch the
> appropriate docs from the server, make emit and log send messages to Firebug
> console). Then you just use the regular debugging functionality builtin to
> Firebug.
>
> It is also possible to extend this environment to help with compliance and
> testing. For example it can emulate rereduce for views, shows with null
> docs etc.
>
> Roger
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAksgi9kACgkQmOOfHg372QT11QCbBZ8g7j/trfCoo52AFEiY0gY5
> Wd8AoKinzQV8LC9izLlNyE6sy8fgYmTd
> =R+Eg
> -----END PGP SIGNATURE-----
>
>
--
Chris Anderson
http://jchrisa.net
http://couch.io
Re: Debugging show/view/list/filter etc code
Posted by Robert Dionne <di...@dionne-associates.com>.
On Dec 10, 2009, at 12:49 AM, Roger Binns wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Trying to debug this code (Javascript) is a royal pain. It is like being
> back in the dark ages adding log() statements. I have resorted to running
> my code separately directly under the 'js' interpreter but it isn't quite
> the same environment. (Sometimes you can even get tracebacks. But you are
> out of luck if you have an exception while handling an exception!) The wiki
> is despairing for views and the situation is no better for
> shows/lists/filters etc.
>
> http://wiki.apache.org/couchdb/HTTP_view_API#Debugging_Views
>
> Anyway I think it is relatively easy to make nice interactive debugging
All the power to you if you really think this is easy. It would certainly add a lot of value.
> possible as a feature of futon maybe with some server side help. My guess
> is that you require Firebug in the client browser and then feed it a page of
> Javascript that emulates the server environment. It would contain the
> defined show/view/list/filter and just enough glue to work (eg fetch the
> appropriate docs from the server, make emit and log send messages to Firebug
> console). Then you just use the regular debugging functionality builtin to
> Firebug.
>
> It is also possible to extend this environment to help with compliance and
> testing. For example it can emulate rereduce for views, shows with null
> docs etc.
>
> Roger
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iEYEARECAAYFAksgi9kACgkQmOOfHg372QT11QCbBZ8g7j/trfCoo52AFEiY0gY5
> Wd8AoKinzQV8LC9izLlNyE6sy8fgYmTd
> =R+Eg
> -----END PGP SIGNATURE-----
>