node-v0.1.18

18 views
Skip to first unread message

r...@tinyclouds.org

unread,
Nov 17, 2009, 9:09:13 AM11/17/09
to nodejs
2009.11.17, Version 0.1.18

* Feature: process.watchFile() process.unwatchFile()

* Feature: "uncaughtException" event on process
(Felix Geisendörfer)

* Feature: 'drain' event to tcp.Connection

* Bugfix: Promise.timeout() blocked the event loop
(Felix Geisendörfer)

* Bugfix: sendBody() and chunked utf8 strings
(Felix Geisendörfer)

* Supply the strerror as a second arg to the tcp.Connection close
event (Johan Sørensen)

* Add EventEmitter.removeListener (frod...@gmail.com)

* Format JSON for inspecting objects (Felix Geisendörfer)

* Upgrade libev to latest CVS


Download: http://s3.amazonaws.com/four.livejournal/20091117/node-v0.1.18.tar.gz

Website: http://nodejs.org/

Documentation: http://nodejs.org/api.html

Tim Caswell

unread,
Nov 17, 2009, 10:26:12 AM11/17/09
to nod...@googlegroups.com
process.watchFile!, I'm excited to try that one out. Is there a way to reload libraries like you can do in python? I'm thinking of using it to monitor source files for changes and reload on change.
> --
>
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=.
>
>

Daniel Bartlett

unread,
Nov 17, 2009, 12:27:24 PM11/17/09
to nod...@googlegroups.com
Hi All,

I've updated the CentOS RPM on my repo:
http://a2b.f-box.org/repo/centos/5/x86_64/repoview/node.html

Cheers,

DanB.

2009/11/17 <r...@tinyclouds.org>:

Ryan Dahl

unread,
Nov 17, 2009, 1:14:21 PM11/17/09
to nod...@googlegroups.com
On Tue, Nov 17, 2009 at 4:26 PM, Tim Caswell <creat...@gmail.com> wrote:
> process.watchFile!, I'm excited to try that one out.  Is there a way to reload libraries like you can do in python?  I'm thinking of using it to monitor source files for changes and reload on change.

Not yet. I hope someone will take a jab at it soon.

Tim Caswell

unread,
Nov 17, 2009, 1:38:35 PM11/17/09
to nod...@googlegroups.com
Hmm, it seems that file watching doesn't work when watching a folder on OSX. Maybe this is a difference between Linux filesystems and the Mac HFS+. I'm not getting modify events when I add or delete files from within the folder.
I don't have my linux laptop with me so I can't test it there. I read through the sources to libev and it said that the mtime should change on the folder and thus fire an event.

Joshaven Potter

unread,
Nov 17, 2009, 1:46:18 PM11/17/09
to nod...@googlegroups.com
Try a VM on your mac...

You should be able to install Ubuntu using the standard ISO.

I had VirtualBox running Ubuntu back when I was running Tiger but I haven't tried with Snow Leopard yet.  I now run Parallels for VM's because it runs Windows better.


--
Sincerely,
Joshaven Potter

"No man making a profession of faith ought to sin, nor one possessed of love to hate his brother. For He that said, “Thou shalt love the Lord thy God,”  said also, “and thy neighbor as thyself.”  Those that profess themselves to be Christ’s are known not only by what they say, but by what they practice. “For the tree is known by its fruit.”" -- Ignatius

Brandon Beacher

unread,
Nov 17, 2009, 1:47:11 PM11/17/09
to nod...@googlegroups.com
Very nice.

In the meantime, here's a rbind script which takes the brute force approach by restarting your node process.

It has been working well for me since node starts fast.


and

Sotonin

unread,
Nov 17, 2009, 3:16:47 PM11/17/09
to nod...@googlegroups.com
Virtualbox is pretty weak for ubuntu. The new version of VMWare 3 runs it a lot smoother and integrated. I recently switched to that. :) It just feel a lot more polished than virtualbox.

Kevin

Keri Henare

unread,
Nov 17, 2009, 3:33:56 PM11/17/09
to nod...@googlegroups.com
I find that Virtualbox tends to be less of a hog on resources than VMware or Parallels, and you can't beat the price :D

---------------------------------------------------
Keri Henare
(Views expressed are not necessarily those of my employer.)

[e] ke...@henare.co.nz
[m] (+64) 021 874 552
[w] kerihenare.com

Felix Geisendörfer

unread,
Nov 17, 2009, 3:47:25 PM11/17/09
to nodejs
Maybe its just me, but I'm a huge fan of VirtualBox. I use it to run
Ubuntu and Windows XP at the moment and it runs awesome on my macbook
pro (4GB Ram, 2.66 Ghz Intel Core 2 Duo).

I have tried using parallels and vmware fusion in the past, and they
are fairly awesome in terms of blending in with the environment.
However, VirtualBox is awesome engineering, it gets faster all the
time and it has beyond awesome network configuration options. The new
beta also has branched snapshots and support for changing the
simulated hardware while the vm is running (insane stuff).

So for people with similar needs, running a rather complex ubuntu
stack locally and testing stuff in IE sometimes, I can highly
recommend virtual box.

-- Felix Geisendörfer aka the_undefined

On Nov 17, 9:16 pm, Sotonin <soto...@gmail.com> wrote:
> Virtualbox is pretty weak for ubuntu. The new version of VMWare 3 runs it a
> lot smoother and integrated. I recently switched to that. :) It just feel a
> lot more polished than virtualbox.
>
> Kevin
>
> On Tue, Nov 17, 2009 at 12:46 PM, Joshaven Potter <yourt...@gmail.com>wrote:
>
>
>
> > Try a VM on your mac...
>
> > FREE VM Server:http://www.virtualbox.org/wiki/Downloads
> > You should be able to install Ubuntu using the standard ISO.
>
> > I had VirtualBox running Ubuntu back when I was running Tiger but I haven't
> > tried with Snow Leopard yet.  I now run Parallels for VM's because it runs
> > Windows better.
>
> > On Tue, Nov 17, 2009 at 1:38 PM, Tim Caswell <creatio...@gmail.com> wrote:
>
> >> Hmm, it seems that file watching doesn't work when watching a folder on
> >> OSX. Maybe this is a difference between Linux filesystems and the Mac HFS+.
> >>  I'm not getting modify events when I add or delete files from within the
> >> folder.
> >> I don't have my linux laptop with me so I can't test it there.  I read
> >> through the sources to libev and it said that the mtime should change on the
> >> folder and thus fire an event.
>
> >> On Nov 17, 2009, at 12:14 PM, Ryan Dahl wrote:
>
> >> > On Tue, Nov 17, 2009 at 4:26 PM, Tim Caswell <creatio...@gmail.com>
> >> wrote:
> >> >> process.watchFile!, I'm excited to try that one out.  Is there a way to
> >> reload libraries like you can do in python?  I'm thinking of using it to
> >> monitor source files for changes and reload on change.
>
> >> > Not yet. I hope someone will take a jab at it soon.
>
> >> > --
>
> >> > You received this message because you are subscribed to the Google
> >> Groups "nodejs" group.
> >> > To post to this group, send email to nod...@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> >> .
> >> > For more options, visit this group at
> >>http://groups.google.com/group/nodejs?hl=.
>
> >> --
>
> >> You received this message because you are subscribed to the Google Groups
> >> "nodejs" group.
> >> To post to this group, send email to nod...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/nodejs?hl=.
>
> > --
> > Sincerely,
> > Joshaven Potter
>
> > "No man making a profession of faith ought to sin, nor one possessed of
> > love to hate his brother. For He that said, “Thou shalt love the Lord thy
> > God,”  said also, “and thy neighbor as thyself.”  Those that profess
> > themselves to be Christ’s are known not only by what they say, but by what
> > they practice. “For the tree is known by its fruit.”" -- Ignatius
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .

Sotonin

unread,
Nov 17, 2009, 4:21:37 PM11/17/09
to nod...@googlegroups.com
Really? The latest version of VirtualBox will not work with shared clipboard. I found if i enabled it, my CPU would go out of control and my mac would be unstable. I had to turn it off to even run it. This was not acceptable so i switched to vmware and havent looked back since. I lock my vmware at 256m of ram anyways. So thats not an issue.

I used to like virtualbox, but ever since sun bought them out the product hasn't been the same imo.

2009/11/17 Felix Geisendörfer <fe...@debuggable.com>
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Ryan Dahl

unread,
Nov 17, 2009, 4:53:27 PM11/17/09
to nod...@googlegroups.com
On Tue, Nov 17, 2009 at 7:38 PM, Tim Caswell <creat...@gmail.com> wrote:
> Hmm, it seems that file watching doesn't work when watching a folder on OSX. Maybe this is a difference between Linux filesystems and the Mac HFS+.  I'm not getting modify events when I add or delete files from within the folder.
> I don't have my linux laptop with me so I can't test it there.  I read through the sources to libev and it said that the mtime should change on the folder and thus fire an event.

It does work in linux.

Tim Caswell

unread,
Nov 17, 2009, 5:26:36 PM11/17/09
to nod...@googlegroups.com
That's what I thought, it may just be because the Mac filesystem works different. Is there a way to monitor a folder for changes in it's contents, or at a minimum to watch for a file in a list of paths to appear.

My use case is this:

I have two folders, an inbox and an outbox. I drop 20 files in the inbox and then start an external process that processes the files. As it works it will create files in the output folder and delete files in the input folder. I would like to register events for the file creations in the output folder and deletes in the input folder. On event machine on linux I just watch the two folders for modify events. Now I would like to do the same, but on osx and linux using node's file watcher.

Jeremy Apthorp

unread,
Nov 17, 2009, 7:11:03 PM11/17/09
to nod...@googlegroups.com
I'm pretty sure OSX does support watching directories, but possibly
using a different mechanism to Linux...

j



2009/11/18 Tim Caswell <creat...@gmail.com>:

Ryan Dahl

unread,
Nov 17, 2009, 7:42:40 PM11/17/09
to nod...@googlegroups.com
Does the mtime not change?
stat . | grep Modify; touch blah; stat . | grep Modify

Ryan Dahl

unread,
Nov 17, 2009, 7:46:37 PM11/17/09
to nod...@googlegroups.com
I just tried it on macintosh. I does indeed work:

sys = require("sys");
process.watchFile(".", function () {
sys.puts("dir changed.")
});

Tim Caswell

unread,
Nov 17, 2009, 7:51:06 PM11/17/09
to nod...@googlegroups.com
Ahh, it does indeed work, I wasn't expecting the 5 second delay and was hitting control+c too fast, thanks for everyone's help. (BTW, anyone know if there is an eta for a kqueue backend for libev and/or node?)

Tautologistics

unread,
Nov 25, 2009, 8:38:49 AM11/25/09
to nodejs
Right now I'm getting an event firing on an untouched file every 4-5
seconds, yet if I watch the directory, actual changes don't fire
event.

Tim Caswell

unread,
Nov 25, 2009, 2:34:26 PM11/25/09
to nod...@googlegroups.com
What OS are you on? The code is pretty simple, it just loops every 4-5 seconds and checks to see if the file has changed since the last poll.
> --
>
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>

Tautologistics

unread,
Nov 25, 2009, 5:10:52 PM11/25/09
to nodejs
Woops, right. I'm running on OSX 10.5.

I'm monitoring activity using fs_usage and there's no activity on the
file, yet watchFile still triggers each loop through.

Tim Caswell

unread,
Nov 25, 2009, 5:16:26 PM11/25/09
to nod...@googlegroups.com
Hmm, seems like you found a bug, can you post your code or a simplified use case to reproduce the issue.

choonkeat

unread,
Nov 25, 2009, 7:32:11 PM11/25/09
to nod...@googlegroups.com
I could replicate it too http://gist.github.com/243125 OS X Snow Leopard

--
choonkeat

Tim Caswell

unread,
Nov 25, 2009, 7:37:11 PM11/25/09
to nod...@googlegroups.com
Looks like the code is triggering events when the atime of the folder is changed.  I'm guessing this is not desired behavior.  I'm currently swamped with homework, I'll look at making a patch later if no one has made one by then.

choonkeat

unread,
Nov 25, 2009, 9:34:33 PM11/25/09
to nod...@googlegroups.com
process.Stat does what it says: watch changes on stat, and emit "change". so it should be considered correct, since stat did change... what's a better way to fix this unexpected behavior of process.watchFile?

--
choonkeat

Tim Caswell

unread,
Nov 25, 2009, 9:39:32 PM11/25/09
to nod...@googlegroups.com
I think of stat as simply a means to an end, if the atime of a file changes, the file itself doesn't change.  It's called watchFile, not watchStatOfFile.  I don't think we should to anything extreme like compare md5 hashes of the file to see if the contents actually changed before emitting a change event, but at a minimum it's expected to ignore stat changes that couldn't possible have been triggered by a file change.

choonkeat

unread,
Nov 25, 2009, 9:53:54 PM11/25/09
to nod...@googlegroups.com
was thinking more along the line of "mtime" instead of content checksum

--
choonkeat

Tim Caswell

unread,
Nov 25, 2009, 10:19:52 PM11/25/09
to nod...@googlegroups.com
agreed

choonkeat

unread,
Nov 26, 2009, 2:30:18 AM11/26/09
to nod...@googlegroups.com

Tautologistics

unread,
Nov 26, 2009, 8:46:32 AM11/26/09
to nodejs
Right now, I've ignored watchFile and am using stat() + mtime compare
directly, which I would imagine is the common expectation for a file
trigger. However, there's also file deletion to consider and the
expected behavior for directory triggers (file modify, create,
delete). To be thorough, passing a mask, specifying that events to
trigger, to watchFile may really be what is needed.

Of course, that's all a bit more work than the fix you were looking at
making =)

choonkeat

unread,
Nov 26, 2009, 2:02:03 PM11/26/09
to nod...@googlegroups.com
Sorry, wasn't too satisfied with the changeset too. Let's try again...

One option is to pass a mask/attribute when listening (callback on any
difference), another option is to receive 2 objects in the callback
method - current stat struct and previous stat struct - for comparison
in js

+1 to first option, like you've suggested.
> --
>
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>
>

--
--
choonkeat

Ryan Dahl

unread,
Nov 26, 2009, 3:48:52 PM11/26/09
to nod...@googlegroups.com
On Wed, Nov 25, 2009 at 4:37 PM, Tim Caswell <creat...@gmail.com> wrote:
> Looks like the code is triggering events when the atime of the folder is
> changed.  I'm guessing this is not desired behavior.  I'm currently swamped
> with homework, I'll look at making a patch later if no one has made one by
> then.

This is the desired behavior. posix.stat() it yourself and compare
mtime, if that's what you want.

choonkeat

unread,
Nov 27, 2009, 1:22:06 AM11/27/09
to nod...@googlegroups.com
I've reverted to have stat callback triggered for any changes (original), and added 2 new parameters for the callback method instead

So, the JS script can now compare stat.mtime != prev.mtime

sys = require("sys");
process.watchFile(".", function (stat, prev) {
  sys.puts("\n[. is now: " + sys.inspect(stat));
  sys.puts("[. was: " + sys.inspect(prev));
});
process.watchFile("foo.txt", function (stat, prev) {
  sys.puts("\n[foo.txt is now: " + sys.inspect(stat));
  sys.puts("[foo.txt was: " + sys.inspect(prev));
});

Happy Thanksgiving & Hari Raya Haji !
--
choonkeat




Ryan Dahl

unread,
Nov 27, 2009, 8:42:01 AM11/27/09
to nod...@googlegroups.com
On Thu, Nov 26, 2009 at 10:22 PM, choonkeat <choo...@gmail.com> wrote:
> I've reverted to have stat callback triggered for any changes (original),
> and added 2 new parameters for the callback method instead
> http://github.com/choonkeat/node/commit/cd5aad6d901e3d3df88af62d7a325c07969dd3cd
> So, the JS script can now compare stat.mtime != prev.mtime

LGTM. Can you put BuildStatsObject() into node.cc and add a test?

choonkeat

unread,
Nov 28, 2009, 5:27:35 AM11/28/09
to nod...@googlegroups.com
Committed http://github.com/choonkeat/node/commit/b1bb6ffacba56a3c4433321bc213981d0f4be6d5

Not very certain about using FunctionTemplate though

--
choonkeat




Ryan Dahl

unread,
Nov 28, 2009, 9:13:38 AM11/28/09
to nodejs
On Sat, Nov 28, 2009 at 11:27 AM, choonkeat <choo...@gmail.com> wrote:
> Committed http://github.com/choonkeat/node/commit/b1bb6ffacba56a3c4433321bc213981d0f4be6d5
> Not very certain about using FunctionTemplate though

I cleaned up some things and added docs. Commited 44d5f21.

choonkeat

unread,
Nov 28, 2009, 10:27:44 AM11/28/09
to nod...@googlegroups.com
Ah.. the changeset helped me understand some of the stuff now. Thanks!

--
choonkeat




Reply all
Reply to author
Forward
0 new messages