Having played with it a bit last night and reading through the JSConf slides (highly recommended) today, I have the very beginnings of an inkling of what fab.js is all about.
First up, let's see if a pull resolves last night's issue in the
fab.nodejs.http
function. I undo my local changes (deleted some code that was failing), then I pull in the new stuff:cstrom@whitefall:~/repos/fab$ git co index.js(amazing how much has changed since just yesterday!)
cstrom@whitefall:~/repos/fab$ gl
remote: Counting objects: 46, done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 41 (delta 18), reused 0 (delta 0)
Unpacking objects: 100% (41/41), done.
From git://github.com/jed/fab
df711aa..a1039a0 master -> origin/master
Updating df711aa..a1039a0
...
Again, I run my all CouchDB databases play server:
cstrom@whitefall:~/repos/fab$ node ./play/all_dbs.jsOK good sign that it hasn't crashed. When I access the
/all_dbs
resource, I get:cstrom@whitefall:~/repos/fab$ curl localhost:4011/all_dbsUgh.
curl: (52) Empty reply from server
Checking out the server, I find:
cstrom@whitefall:~/repos/fab$ node ./play/all_dbs.jsGah! That's the same error that I got last night. Jed had indicated that this was fixed in HEAD, but it looks like all that refactoring reintroduced it. No matter, I replace the
Warning: ClientRequest.prototype.close has been renamed to end()
ReferenceError: back is not defined
at ClientRequest.<anonymous> (/home/cstrom/repos/fab/apps/fab.nodejs.http.js:24:30)
at HTTPParser.onIncoming (http:650:20)
at HTTPParser.onHeadersComplete (http:84:14)
at Client.ondata (http:601:30)
at IOWatcher.callback (net:307:31)
at node.js:748:9
back
with out
(and the closing close
with an end
to eliminate a deprecation warning):.addListener( "response", function( response ) {Now my code is working again:
out({
status: response.statusCode,
headers: response.headers
});
response
.addListener( "data", function( chunk ) {
out({ body: chunk });
})
.addListener( "end", out )
.setBodyEncoding( "utf8" );
})
.end();
cstrom@whitefall:~/repos/fab$ curl localhost:4011/all_dbsI do notice something odd that I cannot quite track down: the third time I access this resource, I get a failure:
["eee","test","seed"]
cstrom@whitefall:~/repos/fab$ curl localhost:4011/all_dbsChecking the stacktrace, I find:
["eee","test","seed"]
cstrom@whitefall:~/repos/fab$ curl localhost:4011/all_dbs
["eee","test","seed"]
cstrom@whitefall:~/repos/fab$ curl localhost:4011/all_dbs
curl: (52) Empty reply from server
cstrom@whitefall:~/repos/fab$ node ./play/all_dbs.jsNot real sure what the problem is there, but it doesn't seem to be with my script (at least it is not included in the backtrace). I investigate a bit longer, but I will leave that for another day.
TypeError: Cannot call method 'replace' of undefined
at /home/cstrom/repos/fab/apps/fab.path.js:17:37
at /home/cstrom/repos/fab/apps/fab.path.js:37:21
at Server.<anonymous> (/home/cstrom/repos/fab/apps/fab.nodejs.js:16:17)
at HTTPParser.onIncoming (http:562:10)
at HTTPParser.onHeadersComplete (http:84:14)
at Client.ondata (http:601:30)
at IOWatcher.callback (net:307:31)
at node.js:748:9
Day #81
Chris,
ReplyDeleteSorry about the regression there, I've fixed it again. I spent yesterday dividing each app into its own file for modularity, and today i'll be writing a bunch of tests. Not sure where this is failing, but I did commit a change just now that fixes an inadvertent variable shadowing.
Stuff like this will be easier to find once we have some tests in place.
Jed
Jed -- Thanks again! I'm not too concerned about the third-time-is-a-failure thing (at least not yet). I will give it a try tonight to see if the variable shadowing was the cause.
ReplyDeleteTonight I'm going to try to play with some of the other built-in apps because I am pretty sure that I still don't *really* grok all of this :)
Chris,
ReplyDeleteOnce the infrastructure stuff settles down, I'm going to be writing a bunch of apps myself. I have a whole wishlist:
http://wiki.github.com/jed/fab/app-ideas