CouchDB Debugger

This is my work on a browser-based debugger for server-side JavaScript code running on CouchDB. This is in the nodejs_couchdb branch in Git.



Start with a simple CouchDB database.

This document has a flag we will use for a breakpoint.

For example, make a temporary view. Break execution if doc.debug_me is true.

Futon has a new panel which lists running JavaScript processes. A nice feature is that breakpoints and debugger; commands do nothing until you have connected to the debugger web app (i.e. clicked a link from the menu).

When you click a link, a debugger application opens up. Nothing much happens; but once the code hits a breakpoint, it springs to life. Here is the window upon running the temporary view.

Notice that all the source code is there, intact.

You can step execution, and use the REPL prompt at the bottom. Notice that commands are executed in the context (scope) of the running code.

Here is a design document with a validation function. We will break the code for any document with .debug_me or any document named "some_doc".

Now, create a new document which will trigger the breakpoint.

Immediately upon clicking "Save" in Futon, the debugger comes alive again.

Notice again that the REPL runs on the server, in the standard CouchDB context. Calling a `log()` function from the debugger produces a standard CouchDB log entry.