[node-dev] Re: Version 0.6.19 (stable)
Ok, here's the new shasums: b6e195900139df1a7c1a2d48b784520c77cb8d61 node-v0.6.19-baddocs.tar.gz ef4f5c1e5f12f6ef3478a794d6a81f59669332f9 node-v0.6.19.msi 781616f33208f532f168633758a648c20e1ea68b node-v0.6.19.pkg f6c5cfbadff4788ac3a95f8263a0c2f4e07444b6 node-v0.6.19.tar.gz 10f729ca236825821d97556441fa64f994cb4ca8 node.exe 5b8cd02e5f92ed6512aabdac11766ad8c1abc436 node.exp 20037e4901de605e08e48d0c85531334912844e3 node.lib c44f62852918d449850014d9b29dd073cb6920a5 node.pdb 04db25c93c5357394941dd2de12cb61959eb82d1 x64/node-v0.6.19.msi f77c77f2e470cfc9071853af2f277ba91d660b9c x64/node.exe fcf26a3f984a3f19804e0567414604b77b1d3bac x64/node.exp bfed2a24f253dbac99379d6f22fc8e9e85ade7ed x64/node.lib 95226c1cc5170ea05c2e54431040f06c3e95e99f x64/node.pdb Sorry for the hassle. The Makefile bug that led to this will be corrected shortly. If you downloaded another copy, it's the same executable. It just contains the v0.6.18 docs in doc/api/api/, which you can safely ignore. On Wed, Jun 6, 2012 at 11:26 AM, Isaac Schlueter i...@izs.me wrote: There's a slight issue with the docs. Some of the API docs were generated with the wrong version, and show v0.6.18 instead of v0.6.19. I'm uploading a new tarball/msi/pkg now. The shasums will change, but the code is still the same. On Wed, Jun 6, 2012 at 9:57 AM, Isaac Schlueter i...@izs.me wrote: 2012.06.06 Version 0.6.19 (stable) * npm: upgrade to 1.1.24 * fs: no end emit after createReadStream.pause() (Andreas Madsen) * vm: cleanup module memory leakage (Marcel Laverdet) * unix: fix loop starvation under high network load (Ben Noordhuis) * unix: remove abort() in ev_unref() (Ben Noordhuis) * windows/tty: never report error after forcibly aborting line-buffered read (Bert Belder) * windows: skip GetFileAttributes call when opening a file (Bert Belder) Source Code: http://nodejs.org/dist/v0.6.19/node-v0.6.19.tar.gz Windows Installer: http://nodejs.org/dist/v0.6.19/node-v0.6.19.msi Windows x64 Files: http://nodejs.org/dist/v0.6.19/x64/ Macintosh Installer (Universal): http://nodejs.org/dist/v0.6.19/node-v0.6.19.pkg Other release files: http://nodejs.org/dist/v0.6.19/ Website: http://nodejs.org/docs/v0.6.19/ Documentation: http://nodejs.org/docs/v0.6.19/api/ Shasums: 950175c82ba3daaa3051be4a29177cc218d59527 node-v0.6.19.msi 5f8cc7c4742f86c0e55007b175f7ccc92a617b4d node-v0.6.19.pkg b6e195900139df1a7c1a2d48b784520c77cb8d61 node-v0.6.19.tar.gz 4bf2163d886334a96fec34d79a6d83794e804707 node.exe 7c38c07bc427c38354062e8aa5235ac8524415ec node.exp c2fd10f5d012da6fb760db6a3e7fe79e3cabf66a node.lib 9e2463beacfdc037f49502cbae4b7810d744b0b4 node.pdb 32acb868834d3c621623410dcf801de544c33d34 x64/node-v0.6.19.msi 8b0f9e0b4da1e08a151aa5722076877f0ecc58a8 x64/node.exe ee71565221487baa173e73132c0080257dee71e1 x64/node.exp 98d2bc87973ffa398cb048c47fdb1c73c38da44b x64/node.lib ca7e545f13e77104d03084981c5e160abaaad1c1 x64/node.pdb
Re: [nodejs] Re: Number of sockets capped when starting nodejs with upstart or supervisord (?!)
Yep, that's a good point, but I was running the process as root in all these scenarios. (At least as shown by *ps aux | grep node)* On Tue, Jun 5, 2012 at 10:43 PM, mscdex msc...@gmail.com wrote: On Jun 5, 8:47 pm, Hugo hhar...@gmail.com wrote: If I start node by hand (sudo /usr/bin/*node server.js *) everything is groovy, I succesfully tested my long-polling server with a few thousand simultaneous connections. Are you sure you are running the server as the same user in both cases (by hand and upstart)? If not, you probably have to also modify the max resources available for the user you're running the server as in your upstart script. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: trying to debug and getting no debugging symbols found on ./node_g
I definetelly shoot myself in my leg somewhere when i change code like that HandleScope scope; LocalValue js_field = LocalValue::New(Null()); js_field = String::New((const char*)(vary2-vary_string)); ... return scope.Close(js_field); to code like that HandleScope scope; LocalValue js_field = LocalValue::New(Null()); Buffer *slowBuffer = Buffer::New(vary2-vary_length); memcpy(Buffer::Data(slowBuffer), (const char*)(vary2-vary_string), vary2-vary_length); LocalObject globalObj = Context::GetCurrent()-Global(); LocalFunction bufferConstructor = LocalFunction::Cast(globalObj-Get(String::New(Buffer))); HandleValue constructorArgs[3] = { slowBuffer-handle_, Integer::New(vary2-vary_length), Integer::New(0) }; js_field = bufferConstructor-NewInstance(3, constructorArgs); ... return scope.Close(js_field); i.e. returns Buffer instead of String. Node strarts to fall with segmentation fault unconditionally. I call that method in a loop. The problem may appear after 100 iterations or after 1. The input data are same for both cases. Am I doing something wrong? 2012/6/5 Denys Khanzhiyev xden...@gmail.com gdb --args ./node_g ../node_firebird/issues/issue10.js GNU gdb (GDB) CentOS (7.0.1-42.el5.centos) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i386-redhat-linux-gnu. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /root/node/node_g...(no debugging symbols found)...done. Trying to catch segfault and all I get in backtrace Program received signal SIGSEGV, Segmentation fault. 0x578bbeaa in ?? () (gdb) backtrace #0 0x578bbeaa in ?? () #1 0x4aaeb361 in ?? () #2 0x478517a1 in ?? () #3 0x578bbe61 in ?? () #4 0x000c in ?? () #5 0x578acf46 in ?? () #6 0x in ?? () ]# ./node_g -v v0.6.13 built with ./configure --debug make any help? Thank you! -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: Number of sockets capped when starting nodejs with upstart or supervisord (?!)
On Jun 6, 2:20 am, Hugues Hardel hhar...@gmail.com wrote: Yep, that's a good point, but I was running the process as root in all these scenarios. (At least as shown by *ps aux | grep node)* I hope you're not using the code in that gist. It's outdated. Since it seems like you're doing realtime-y kind of stuff, have you tried or thought about using socket.io? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
RE: [ANN] [nodejs] - winstond logging server
This looks awesome Marak! Sent from my Windows Phone -- From: Marak Squires Sent: 6/4/2012 2:14 PM To: nodejs Subject: [ANN] [nodejs] - winstond logging server Hello Internet Friends - As part of the Flatiron tool-chain, Nodejitsu has just released a new multi-transport logging server Winstond ( https://github.com/flatiron/winstond ) Winstond is based on the popular multi-transport Winston logging library ( https://github.com/flatiron/winston ) with 15+ supported transports. They share a bunch of a code! Read more about how they work at http://blog.nodejitsu.com/introducing-winstond -- -- Marak Squires Co-founder and Chief Evangelist Nodejitsu, Inc. marak.squi...@gmail.com -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] value of _this_ within callback function ?
Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
This should help... http://howtonode.org/what-is-this On Wed, Jun 6, 2012 at 5:23 PM, Jérémy Lal holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
I don't think it tells why the result of the snippet is : { oncomplete: [Function] } I still can't tell what is this object... does node.js follow some convention about the context in which a function is called back from a library call ? Jérémy. On 06/06/2012 14:06, Anand George wrote: This should help... http://howtonode.org/what-is-this On Wed, Jun 6, 2012 at 5:23 PM, Jérémy Lal holi...@gmail.com mailto:holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com mailto:nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com mailto:nodejs%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
For the case specified, if you look up http://nodejs.org/api/fs.html#fs_fs_stat_path_callback the function definition takes the form fs.stat(path, [callback]) with callback in the form function(err, stats). You'll notice that the callback has two arguments. One is the err status and the other the result, in this case stats. Most Node.js libraries seem to follow this convention. Therefore you wouldn't have to use 'this' except when you use the constructor. The function is called passing the required parameter, in this case 'path' and a template for the callback, something like require('fs').stat('file.txt', function(err, result) { console.log('Total bytes = ' + result.size); }); will log 'Total bytes = 10' to the console. You could even log the complete object which will output something like { dev: 2049, ino: 28581379, mode: 33188, nlink: 1, uid: 1000, gid: 1000, rdev: 0, size: 10, blksize: 4096, blocks: 8, atime: Wed, 06 Jun 2012 13:16:22 GMT, mtime: Wed, 06 Jun 2012 13:16:21 GMT, ctime: Wed, 06 Jun 2012 13:16:21 GMT } So the convention is to call a function passing the required parameters and you get the results wrapped up in the callback. Hope this helps. On Wed, Jun 6, 2012 at 5:53 PM, Jérémy Lal holi...@gmail.com wrote: I don't think it tells why the result of the snippet is : { oncomplete: [Function] } I still can't tell what is this object... does node.js follow some convention about the context in which a function is called back from a library call ? Jérémy. On 06/06/2012 14:06, Anand George wrote: This should help... http://howtonode.org/what-is-this On Wed, Jun 6, 2012 at 5:23 PM, Jérémy Lal holi...@gmail.com mailto: holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.commailto: nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com mailto: nodejs%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] nodejs and android c2dm
Hello list, there is someone that used node.js in the server side implementation of the android cloud to device system[1]? I have user the library from SpeCT[2], but I have this strange problem: * if I send one notify at time the clients receive the push (but this solution is very slow), ratio 10 messages/seconds * if I try to send the notification in parallel (5 at time) the clients don't receive any notify, the ratio is about 170 messages/seconds any experience/hints? Sorry for the bad english [1]https://developers.google.com/android/c2dm/ [2]https://github.com/SpeCT/node-c2dm -- Luca Morettoni luca(AT)morettoni.net | http://www.morettoni.net gtalk/msn: luca(AT)morettoni.net | http://twitter.com/morettoni Google+ profile: http://bit.ly/morettoni_plus Member of Python User Group Perugia: http://www.pypg.org/ -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] process.nextTick in a callback
Hi! Have been reading up on process.nextTick and found this one rather odd. It's forcing the calling function to run again. function addasync(no1, no2, result) { res = no1 + no2; this.result = result(false, res); process.nextTick(function() { this.result = result(true, res); }); }; addasync(1, 2, function(err, res) { console.log(res); }); function addsync(no1, no2) { return (no1 + no2); } console.log(addsync(4, 2)); When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
The _this_ inside process.nextTick seems quite odd to me.. -- Diogo Resende On Wednesday, June 6, 2012 at 14:31 , Anand George wrote: Hi! Have been reading up on process.nextTick and found this one rather odd. It's forcing the calling function to run again. function addasync(no1, no2, result) { res = no1 + no2; this.result = result(false, res); process.nextTick(function() { this.result = result(true, res); }); }; addasync(1, 2, function(err, res) { console.log(res); }); function addsync(no1, no2) { return (no1 + no2); } console.log(addsync(4, 2)); When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com (mailto:nodejs@googlegroups.com) To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com (mailto:nodejs+unsubscr...@googlegroups.com) For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
Even without the 'this' inside process.nextTick it returns the same result. On Wed, Jun 6, 2012 at 7:05 PM, Diogo Resende drese...@thinkdigital.ptwrote: The _this_ inside process.nextTick seems quite odd to me.. -- Diogo Resende On Wednesday, June 6, 2012 at 14:31 , Anand George wrote: Hi! Have been reading up on process.nextTick and found this one rather odd. It's forcing the calling function to run again. function addasync(no1, no2, result) { res = no1 + no2; this.result = result(false, res); process.nextTick(function() { this.result = result(true, res); }); }; addasync(1, 2, function(err, res) { console.log(res); }); function addsync(no1, no2) { return (no1 + no2); } console.log(addsync(4, 2)); When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
On Wed, Jun 6, 2012 at 3:31 PM, Anand George mranandgeo...@gmail.com wrote: When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. This happens because the code does what it has to do. It's forcing the calling function to run again. I don't understand that. What did you expect? Maybe only one line with 3? But the code calls the callback two times. ??? :-) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
My guess: it's part of the inner guts of Node.js I have a tentative breadcrumb See https://github.com/joyent/node/blob/master/lib/fs.js#L31 that binding.stat is internally mapped to this Stat function: https://github.com/joyent/node/blob/master/src/node_file.cc#L353 notice ASYNC_CALL(stat, args[1], *path) That ASYNC_CALL is https://github.com/joyent/node/blob/master/src/node_file.cc#L225 #define ASYNC_CALL(func, callback, ...) \ FSReqWrap* req_wrap = new FSReqWrap(#func); \ int r = uv_fs_##func(uv_default_loop(), req_wrap-req_,\ __VA_ARGS__, After);\ req_wrap-object_-Set(oncomplete_sym, callback); \ req_wrap-Dispatched(); \ if (r 0) {\ uv_fs_t* req = req_wrap-req_; \ req-result = r; \ req-path = NULL; \ req-errorno = uv_last_error(uv_default_loop()).code; \ After(req); \ } \ return scope.Close(req_wrap-object_); There is a NEW object, req_wrap, enriched with the callback in its property oncomplete_sym My guess: when the callback is finally called, that req_wrap object is used as its this. But it's only guess All this, apparently, is relative to fs module. On Wed, Jun 6, 2012 at 9:23 AM, Jérémy Lal holi...@gmail.com wrote: I don't think it tells why the result of the snippet is : { oncomplete: [Function] } I still can't tell what is this object... does node.js follow some convention about the context in which a function is called back from a library call ? Jérémy. On 06/06/2012 14:06, Anand George wrote: This should help... http://howtonode.org/what-is-this On Wed, Jun 6, 2012 at 5:23 PM, Jérémy Lal holi...@gmail.com mailto: holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.commailto: nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com mailto: nodejs%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
this is crazy i think that what Anand is might want to do is this: function addAsync(no1, no2, cb) { process.nextTick(function() { res = no1 + no2; cb(null, res); }); }; addAsync(1, 2, function(err, res) { console.log(res); }); in order to queue the *intensive CPU operation of adding two numbers* for the next tick in the event loop.. 2012/6/6 Oliver Leics oliver.le...@gmail.com On Wed, Jun 6, 2012 at 3:31 PM, Anand George mranandgeo...@gmail.com wrote: When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. This happens because the code does what it has to do. It's forcing the calling function to run again. I don't understand that. What did you expect? Maybe only one line with 3? But the code calls the callback two times. ??? :-) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
The first call to addasync is running in sync way (hmmm... I should write a better explanation, but my English is limited ;-)...) Then, it prints the first 3. The call to addsyn is runnning after that, then it prints the 6 Meanwhile, the first addasync queued a new call in process.nextTick. In the next tick, that call will be run, producing the second 3 Make sense? On Wed, Jun 6, 2012 at 10:31 AM, Anand George mranandgeo...@gmail.comwrote: Hi! Have been reading up on process.nextTick and found this one rather odd. It's forcing the calling function to run again. function addasync(no1, no2, result) { res = no1 + no2; this.result = result(false, res); process.nextTick(function() { this.result = result(true, res); }); }; addasync(1, 2, function(err, res) { console.log(res); }); function addsync(no1, no2) { return (no1 + no2); } console.log(addsync(4, 2)); When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
A simple one-line session in the repl gives you the answer right away: require('fs').stat(., function (err, stat) { console.log(this, this, this.__proto__ === Object.prototype, this.oncomplete === arguments.callee) }) // OUTPUTS: this { oncomplete: [Function] } true true As you can see, the value of this is a simple javascript Object instance with an oncomplete function that is the callback you passed to the call. I believe the value of this is not defined per the node public API in callbacks. On Wed, Jun 6, 2012 at 6:53 AM, Jérémy Lal holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
Here is a slightly cleaned up version of the code with comments as to why it's doing what it does. (the `this.result` code didn't affect the output and was a distraction since it was polluting the global scope) function addasync(no1, no2, callback) { res = no1 + no2; callback(false, res); // Will log the first 3 process.nextTick(function () { // nextTick returns right away, so we don't get 3 yet callback(true, res); // Will log the last 3 }); }; function addsync(no1, no2) { return (no1 + no2); } addasync(1, 2, function(err, res) { console.log(res); // Will get called twice, once before returning and once in the nextTick }); console.log(addsync(4, 2)); // Will log the 6 in the middle On Wed, Jun 6, 2012 at 8:31 AM, Anand George mranandgeo...@gmail.comwrote: Hi! Have been reading up on process.nextTick and found this one rather odd. It's forcing the calling function to run again. function addasync(no1, no2, result) { res = no1 + no2; this.result = result(false, res); process.nextTick(function() { this.result = result(true, res); }); }; addasync(1, 2, function(err, res) { console.log(res); }); function addsync(no1, no2) { return (no1 + no2); } console.log(addsync(4, 2)); When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Event loop blocking. How to detect?
On Wed, Jun 6, 2012 at 5:42 AM, Tim Dickinson price.ti...@gmail.com wrote: Thats not what im asking about. There are no while loop, my for loops even use the nextTick. I need to know what kind of delay there is, not if the code is blocking. The longer the delay the more work has been quoted. Do I need to point out that you, the OP, picked Event loop blocking. How to detect? as the subject of this topic? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
Jose. That's what I started doing and it was giving expected results 3 6 Then I was just trying out some testing to see the output in each case and was surprised to find this. The other options I tried are these: function addasync(no1, no2, result) { res = no1 + no2; }; returns 6. Here result is not being updated and therefore the console does not log the output from this function. So in this case the calling function is running even without getting it's callback updated. In the next case function addasync(no1, no2, result) { res = no1 + no2; result = result(false, res); process.nextTick(function() { }); }; it returns 3 6 It is running like a synchronous function. The function is running with both parameters available and thus the console log. The third case is the one I listed initially. Here the function reruns after its callback parameter is updated. Is this expected behavior. On Wed, Jun 6, 2012 at 7:23 PM, José F. Romaniello jfromanie...@gmail.comwrote: this is crazy i think that what Anand is might want to do is this: function addAsync(no1, no2, cb) { process.nextTick(function() { res = no1 + no2; cb(null, res); }); }; addAsync(1, 2, function(err, res) { console.log(res); }); in order to queue the *intensive CPU operation of adding two numbers* for the next tick in the event loop.. 2012/6/6 Oliver Leics oliver.le...@gmail.com On Wed, Jun 6, 2012 at 3:31 PM, Anand George mranandgeo...@gmail.com wrote: When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. This happens because the code does what it has to do. It's forcing the calling function to run again. I don't understand that. What did you expect? Maybe only one line with 3? But the code calls the callback two times. ??? :-) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
Anand, it appears some fundamentals about closures, scope, and callbacks are confusing you. Some tips that may help. 1. Always use `var` when creating a new local variable or it will be declared global and clobber existing variables. 2. Your `result` argument is a function. Every time you call it, it's body will be executed. 3. Node style callback functions should be of the form (err, result) and only be called once. The err argument is usually either `null` or an instance of `Error`, not `true` or `false` 4. The return value of callbacks usually doesn't matter and indeed in your case, you're not returning anything from the callback. Then what are you trying to store in `this.result` 5. `this` is `undefined` or the global scope (depending on if you're using strict mode) for normal functions not called as part of an object. In this case it's global scope. Good luck continuing to learn the wonderful language of JavaScript :) On Wed, Jun 6, 2012 at 9:12 AM, Anand George mranandgeo...@gmail.comwrote: Jose. That's what I started doing and it was giving expected results 3 6 Then I was just trying out some testing to see the output in each case and was surprised to find this. The other options I tried are these: function addasync(no1, no2, result) { res = no1 + no2; }; returns 6. Here result is not being updated and therefore the console does not log the output from this function. So in this case the calling function is running even without getting it's callback updated. In the next case function addasync(no1, no2, result) { res = no1 + no2; result = result(false, res); process.nextTick(function() { }); }; it returns 3 6 It is running like a synchronous function. The function is running with both parameters available and thus the console log. The third case is the one I listed initially. Here the function reruns after its callback parameter is updated. Is this expected behavior. On Wed, Jun 6, 2012 at 7:23 PM, José F. Romaniello jfromanie...@gmail.com wrote: this is crazy i think that what Anand is might want to do is this: function addAsync(no1, no2, cb) { process.nextTick(function() { res = no1 + no2; cb(null, res); }); }; addAsync(1, 2, function(err, res) { console.log(res); }); in order to queue the *intensive CPU operation of adding two numbers*for the next tick in the event loop.. 2012/6/6 Oliver Leics oliver.le...@gmail.com On Wed, Jun 6, 2012 at 3:31 PM, Anand George mranandgeo...@gmail.com wrote: When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. This happens because the code does what it has to do. It's forcing the calling function to run again. I don't understand that. What did you expect? Maybe only one line with 3? But the code calls the callback two times. ??? :-) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] process.nextTick in a callback
Thanks Tim. That cleared up a lot of misconceptions, especially regards callback functions. Just love this community :) On Wed, Jun 6, 2012 at 7:49 PM, Tim Caswell t...@creationix.com wrote: Anand, it appears some fundamentals about closures, scope, and callbacks are confusing you. Some tips that may help. 1. Always use `var` when creating a new local variable or it will be declared global and clobber existing variables. 2. Your `result` argument is a function. Every time you call it, it's body will be executed. 3. Node style callback functions should be of the form (err, result) and only be called once. The err argument is usually either `null` or an instance of `Error`, not `true` or `false` 4. The return value of callbacks usually doesn't matter and indeed in your case, you're not returning anything from the callback. Then what are you trying to store in `this.result` 5. `this` is `undefined` or the global scope (depending on if you're using strict mode) for normal functions not called as part of an object. In this case it's global scope. Good luck continuing to learn the wonderful language of JavaScript :) On Wed, Jun 6, 2012 at 9:12 AM, Anand George mranandgeo...@gmail.comwrote: Jose. That's what I started doing and it was giving expected results 3 6 Then I was just trying out some testing to see the output in each case and was surprised to find this. The other options I tried are these: function addasync(no1, no2, result) { res = no1 + no2; }; returns 6. Here result is not being updated and therefore the console does not log the output from this function. So in this case the calling function is running even without getting it's callback updated. In the next case function addasync(no1, no2, result) { res = no1 + no2; result = result(false, res); process.nextTick(function() { }); }; it returns 3 6 It is running like a synchronous function. The function is running with both parameters available and thus the console log. The third case is the one I listed initially. Here the function reruns after its callback parameter is updated. Is this expected behavior. On Wed, Jun 6, 2012 at 7:23 PM, José F. Romaniello jfromanie...@gmail.com wrote: this is crazy i think that what Anand is might want to do is this: function addAsync(no1, no2, cb) { process.nextTick(function() { res = no1 + no2; cb(null, res); }); }; addAsync(1, 2, function(err, res) { console.log(res); }); in order to queue the *intensive CPU operation of adding two numbers*for the next tick in the event loop.. 2012/6/6 Oliver Leics oliver.le...@gmail.com On Wed, Jun 6, 2012 at 3:31 PM, Anand George mranandgeo...@gmail.com wrote: When I run this code I get the following output. 3 6 3. Any ideas why this could be happening. This happens because the code does what it has to do. It's forcing the calling function to run again. I don't understand that. What did you expect? Maybe only one line with 3? But the code calls the callback two times. ??? :-) -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/
Re: [nodejs] Re: Event loop blocking. How to detect?
This doesn't change the fact that external monitoring is still going to be better. On Wed, Jun 6, 2012 at 1:27 AM, Jeff Willden jeff.will...@gmail.com wrote: Some readers are not getting the point. When running node in a production environment, it is assumed that the app has no blatant infinite loops. Yes, that would block the event loop and prevent anything from running, but if you've done that, you should take Intro to Node 101, or maybe the remedial class... In a production environment, we're concerned about long running events that might be blocking the event loop. If your code is doing database calls, then it's yielding to the event loop. No problem there. But then if you run a bunch of processing on that using synchronous code, and that processing takes longer than whatever threshold you give in the code I posted, then it will tell you. We're not concerned as much about overall request time, because during the time it's processing the request, it's probably yielding. For newbies, yielding means that you perform some action and pass it a callback, and when that action is done, it calls the callback. Users see this all over in node code. That doesn't necessarily mean it yields though... Case scenario: we had a bunch of db calls to load data that would be processed (sorted, organized, transformed, etc) and converted to json and then fed to the client. That db calls yield each time a db call is made. No problem. The processing was all linear programming. Problem: for large data sets it was taking over our threshold. When you have more concurrent requests than the number of instances of node (we're using cluster) then every instance is busy and your server goes unresponsive. BAD news. We had to change some calls to accept a callback, and then it would call the callback inside a process.nextTick(). That made the code async, and the problem disappeared. We could ramp up with hundreds of users and the users with only a little data got served fast, the users with lots of data not quite as fast, but at least they weren't blocking other users. People often misunderstand how to build server-side apps with Node. With async coding in node, you can easily outmatch performance for lots of other environments. With synchronous code in node, you can easily have a dead server. Node is great, but it's oh-so-easy to shoot yourself in the foot. Gotta be really careful about excessive runs of synchronous code. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
Thank you for that perfect answer. On 06/06/2012 16:04, Tim Caswell wrote: A simple one-line session in the repl gives you the answer right away: require('fs').stat(., function (err, stat) { console.log(this, this, this.__proto__ === Object.prototype, this.oncomplete === arguments.callee) }) // OUTPUTS: this { oncomplete: [Function] } true true As you can see, the value of this is a simple javascript Object instance with an oncomplete function that is the callback you passed to the call. I believe the value of this is not defined per the node public API in callbacks. On Wed, Jun 6, 2012 at 6:53 AM, Jérémy Lal holi...@gmail.com mailto:holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); Jérémy. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com mailto:nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com mailto:nodejs%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Event loop blocking. How to detect?
this might sound very stupid,... but wouldn't be useful to have a parameter or something to set the max milliseconds a tick can take? node myapp.js --tick-timeout 6 this means if you have a while(true), or something than takes more than a minute fail!, raise an exception in the application so you can log it on the process uncaughException event. and something like forever will restart the process. Maybe there is no way to implement this right now, or maybe there is something like this already... cheers, 2012/6/6 Matt hel...@gmail.com This doesn't change the fact that external monitoring is still going to be better. On Wed, Jun 6, 2012 at 1:27 AM, Jeff Willden jeff.will...@gmail.comwrote: Some readers are not getting the point. When running node in a production environment, it is assumed that the app has no blatant infinite loops. Yes, that would block the event loop and prevent anything from running, but if you've done that, you should take Intro to Node 101, or maybe the remedial class... In a production environment, we're concerned about long running events that might be blocking the event loop. If your code is doing database calls, then it's yielding to the event loop. No problem there. But then if you run a bunch of processing on that using synchronous code, and that processing takes longer than whatever threshold you give in the code I posted, then it will tell you. We're not concerned as much about overall request time, because during the time it's processing the request, it's probably yielding. For newbies, yielding means that you perform some action and pass it a callback, and when that action is done, it calls the callback. Users see this all over in node code. That doesn't necessarily mean it yields though... Case scenario: we had a bunch of db calls to load data that would be processed (sorted, organized, transformed, etc) and converted to json and then fed to the client. That db calls yield each time a db call is made. No problem. The processing was all linear programming. Problem: for large data sets it was taking over our threshold. When you have more concurrent requests than the number of instances of node (we're using cluster) then every instance is busy and your server goes unresponsive. BAD news. We had to change some calls to accept a callback, and then it would call the callback inside a process.nextTick(). That made the code async, and the problem disappeared. We could ramp up with hundreds of users and the users with only a little data got served fast, the users with lots of data not quite as fast, but at least they weren't blocking other users. People often misunderstand how to build server-side apps with Node. With async coding in node, you can easily outmatch performance for lots of other environments. With synchronous code in node, you can easily have a dead server. Node is great, but it's oh-so-easy to shoot yourself in the foot. Gotta be really careful about excessive runs of synchronous code. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: Event loop blocking. How to detect?
It would be hard to preempt the thread since node is single threaded, but you could wrap the event sources and measure how long a tick took to run. Then if it took longer than a threshold you could log a warning or throw an error. Sadly there is no node api for easy wrapping of the event sources yet, but I did it manually once for a module. https://github.com/CrabDude/trycatch/blob/master/lib/hook.js On Wed, Jun 6, 2012 at 9:42 AM, José F. Romaniello jfromanie...@gmail.comwrote: this might sound very stupid,... but wouldn't be useful to have a parameter or something to set the max milliseconds a tick can take? node myapp.js --tick-timeout 6 this means if you have a while(true), or something than takes more than a minute fail!, raise an exception in the application so you can log it on the process uncaughException event. and something like forever will restart the process. Maybe there is no way to implement this right now, or maybe there is something like this already... cheers, 2012/6/6 Matt hel...@gmail.com This doesn't change the fact that external monitoring is still going to be better. On Wed, Jun 6, 2012 at 1:27 AM, Jeff Willden jeff.will...@gmail.comwrote: Some readers are not getting the point. When running node in a production environment, it is assumed that the app has no blatant infinite loops. Yes, that would block the event loop and prevent anything from running, but if you've done that, you should take Intro to Node 101, or maybe the remedial class... In a production environment, we're concerned about long running events that might be blocking the event loop. If your code is doing database calls, then it's yielding to the event loop. No problem there. But then if you run a bunch of processing on that using synchronous code, and that processing takes longer than whatever threshold you give in the code I posted, then it will tell you. We're not concerned as much about overall request time, because during the time it's processing the request, it's probably yielding. For newbies, yielding means that you perform some action and pass it a callback, and when that action is done, it calls the callback. Users see this all over in node code. That doesn't necessarily mean it yields though... Case scenario: we had a bunch of db calls to load data that would be processed (sorted, organized, transformed, etc) and converted to json and then fed to the client. That db calls yield each time a db call is made. No problem. The processing was all linear programming. Problem: for large data sets it was taking over our threshold. When you have more concurrent requests than the number of instances of node (we're using cluster) then every instance is busy and your server goes unresponsive. BAD news. We had to change some calls to accept a callback, and then it would call the callback inside a process.nextTick(). That made the code async, and the problem disappeared. We could ramp up with hundreds of users and the users with only a little data got served fast, the users with lots of data not quite as fast, but at least they weren't blocking other users. People often misunderstand how to build server-side apps with Node. With async coding in node, you can easily outmatch performance for lots of other environments. With synchronous code in node, you can easily have a dead server. Node is great, but it's oh-so-easy to shoot yourself in the foot. Gotta be really careful about excessive runs of synchronous code. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines:
Re: [nodejs] Re: Event loop blocking. How to detect?
cool, i think this comment is the exact think I was thinking: https://github.com/joyent/node/issues/2395#issuecomment-3232185 but configurable.. 2012/6/6 Koichi Kobayashi koic...@improvement.jp Here is similar proposal: https://github.com/joyent/node/issues/2395 On Wed, 6 Jun 2012 11:42:30 -0300, Jose F. Romaniello jfromanie...@gmail.com wrote: this might sound very stupid,... but wouldn't be useful to have a parameter or something to set the max milliseconds a tick can take? node myapp.js --tick-timeout 6 this means if you have a while(true), or something than takes more than a minute fail!, raise an exception in the application so you can log it on the process uncaughException event. and something like forever will restart the process. Maybe there is no way to implement this right now, or maybe there is something like this already... cheers, 2012/6/6 Matt hel...@gmail.com This doesn't change the fact that external monitoring is still going to be better. On Wed, Jun 6, 2012 at 1:27 AM, Jeff Willden jeff.will...@gmail.com wrote: Some readers are not getting the point. When running node in a production environment, it is assumed that the app has no blatant infinite loops. Yes, that would block the event loop and prevent anything from running, but if you've done that, you should take Intro to Node 101, or maybe the remedial class... In a production environment, we're concerned about long running events that might be blocking the event loop. If your code is doing database calls, then it's yielding to the event loop. No problem there. But then if you run a bunch of processing on that using synchronous code, and that processing takes longer than whatever threshold you give in the code I posted, then it will tell you. We're not concerned as much about overall request time, because during the time it's processing the request, it's probably yielding. For newbies, yielding means that you perform some action and pass it a callback, and when that action is done, it calls the callback. Users see this all over in node code. That doesn't necessarily mean it yields though... Case scenario: we had a bunch of db calls to load data that would be processed (sorted, organized, transformed, etc) and converted to json and then fed to the client. That db calls yield each time a db call is made. No problem. The processing was all linear programming. Problem: for large data sets it was taking over our threshold. When you have more concurrent requests than the number of instances of node (we're using cluster) then every instance is busy and your server goes unresponsive. BAD news. We had to change some calls to accept a callback, and then it would call the callback inside a process.nextTick(). That made the code async, and the problem disappeared. We could ramp up with hundreds of users and the users with only a little data got served fast, the users with lots of data not quite as fast, but at least they weren't blocking other users. People often misunderstand how to build server-side apps with Node. With async coding in node, you can easily outmatch performance for lots of other environments. With synchronous code in node, you can easily have a dead server. Node is great, but it's oh-so-easy to shoot yourself in the foot. Gotta be really careful about excessive runs of synchronous code. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting
[nodejs] questions about profiling nodejs
I installed node-inspector and v8-profiler on my server and I am able to debug the javascript remotely. I am also able to do: var profiler = require('v8-profiler'); var snapshot = profiler.takeSnapshot([name]) to take a snapshot within the app. The only problem is that I only see the scripts and counsel table in the inspector, I do not see the profile tab. I was wondering what might cause this? Is there a problem with node-inspector finding the v8-profiler? Any help would be appreciated, thanks -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: questions about profiling nodejs
sorry there is a typo, it should read The only problem is that I only see the scripts and counsel tab in the inspector On Wednesday, June 6, 2012 11:40:05 AM UTC-4, marcucio wrote: I installed node-inspector and v8-profiler on my server and I am able to debug the javascript remotely. I am also able to do: var profiler = require('v8-profiler'); var snapshot = profiler.takeSnapshot([name]) to take a snapshot within the app. The only problem is that I only see the scripts and counsel table in the inspector, I do not see the profile tab. I was wondering what might cause this? Is there a problem with node-inspector finding the v8-profiler? Any help would be appreciated, thanks -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: trying to debug and getting no debugging symbols found on ./node_g
Try changing the String::New(Buffer) part to String::NewSymbol(Buffer). Idk why, but that fixed some seg faults I was experiencing using similar code. On Wed, Jun 6, 2012 at 12:11 AM, Denys Khanzhiyev xden...@gmail.com wrote: I definetelly shoot myself in my leg somewhere when i change code like that HandleScope scope; LocalValue js_field = LocalValue::New(Null()); js_field = String::New((const char*)(vary2-vary_string)); ... return scope.Close(js_field); to code like that HandleScope scope; LocalValue js_field = LocalValue::New(Null()); Buffer *slowBuffer = Buffer::New(vary2-vary_length); memcpy(Buffer::Data(slowBuffer), (const char*)(vary2-vary_string), vary2-vary_length); LocalObject globalObj = Context::GetCurrent()-Global(); LocalFunction bufferConstructor = LocalFunction::Cast(globalObj-Get(String::New(Buffer))); HandleValue constructorArgs[3] = { slowBuffer-handle_, Integer::New(vary2-vary_length), Integer::New(0) }; js_field = bufferConstructor-NewInstance(3, constructorArgs); ... return scope.Close(js_field); i.e. returns Buffer instead of String. Node strarts to fall with segmentation fault unconditionally. I call that method in a loop. The problem may appear after 100 iterations or after 1. The input data are same for both cases. Am I doing something wrong? 2012/6/5 Denys Khanzhiyev xden...@gmail.com gdb --args ./node_g ../node_firebird/issues/issue10.js GNU gdb (GDB) CentOS (7.0.1-42.el5.centos) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i386-redhat-linux-gnu. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /root/node/node_g...(no debugging symbols found)...done. Trying to catch segfault and all I get in backtrace Program received signal SIGSEGV, Segmentation fault. 0x578bbeaa in ?? () (gdb) backtrace #0 0x578bbeaa in ?? () #1 0x4aaeb361 in ?? () #2 0x478517a1 in ?? () #3 0x578bbe61 in ?? () #4 0x000c in ?? () #5 0x578acf46 in ?? () #6 0x in ?? () ]# ./node_g -v v0.6.13 built with ./configure --debug make any help? Thank you! -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: questions about profiling nodejs
It you app is HTTP server and you open it in browser, than profiling tab in web inspector refers to your page javascript, not server code. Use https://github.com/c4milo/node-webkit-agent if you want to monitor the app. среда, 6 июня 2012 г., 19:40:05 UTC+4 пользователь marcucio написал: I installed node-inspector and v8-profiler on my server and I am able to debug the javascript remotely. I am also able to do: var profiler = require('v8-profiler'); var snapshot = profiler.takeSnapshot([name]) to take a snapshot within the app. The only problem is that I only see the scripts and counsel table in the inspector, I do not see the profile tab. I was wondering what might cause this? Is there a problem with node-inspector finding the v8-profiler? Any help would be appreciated, thanks -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Everyauth Errors
I belive you need to return the promise outside the callback... a la... .findOrCreateUser( function( etc. ) { var promise = this.Promise(); // lookup user if (user) { promise.fulfull(user); } else { promise.fail(can't find user); } }); return promise; On Tue, Jun 5, 2012 at 4:23 PM, Skyler Brungardt colorfulf...@gmail.comwrote: everyauth.facebook .appId('[[my app id]]') .appSecret('[[my app secret key]]') .scope('email') .handleAuthCallbackError(function(req, res) { }) .findOrCreateUser(function(session, accessToken, accessTokExtra, fbUserMetaData) { var promise = this.Promise(); promise.fulfill('test'); return promise; }) .redirectPath('/'); -Skyler On Jun 5, 2012, at 15:44 PM, Amal wrote: everyauth.facebook .appId('[[my app id]]') .appSecret('[[my app secret key]]') .scope('email') .handleAuthCallbackError(function(req, res) { }) .findOrCreateUser(function(session, accessToken, accessTokExtra, fbUserMetaData) { console.log(fbUserMetaData); }) .redirectPath('/'); -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: questions about profiling nodejs
I understand the difference between remote and local debugging, I was using the node-inspector library on the server which allows you to debug the server code through a different port. Debugging the server code with node-inspect is fine but it is supposed to allow you access to the Profiles tab which does not work for me. I tried to use the library you suggested, I got as far as sending the signal to the process and getting webkit-devtools-agent started on 127.0.0.1:1337 but when I go to: http://c4milo.github.com/node-webkit-agent/19.0.1084.46/inspector.html?host=(my host):1337page=0 I get the following page: https://lh4.googleusercontent.com/-Os2Wr2qT3X0/T8-KQRFDPvI/GYA/5tAM2ZB5KAk/s1600/Screen+Shot+2012-06-06+at+12.49.34+PM.png On Wednesday, June 6, 2012 12:16:19 PM UTC-4, Oleg Efimov (Sannis) wrote: It you app is HTTP server and you open it in browser, than profiling tab in web inspector refers to your page javascript, not server code. Use https://github.com/c4milo/node-webkit-agent if you want to monitor the app. среда, 6 июня 2012 г., 19:40:05 UTC+4 пользователь marcucio написал: I installed node-inspector and v8-profiler on my server and I am able to debug the javascript remotely. I am also able to do: var profiler = require('v8-profiler'); var snapshot = profiler.takeSnapshot([name]) to take a snapshot within the app. The only problem is that I only see the scripts and counsel table in the inspector, I do not see the profile tab. I was wondering what might cause this? Is there a problem with node-inspector finding the v8-profiler? Any help would be appreciated, thanks -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: trying to debug and getting no debugging symbols found on ./node_g
Oh ! Thanks! THAT WORKS! 2012/6/6 Nathan Rajlich nat...@tootallnate.net Try changing the String::New(Buffer) part to String::NewSymbol(Buffer). Idk why, but that fixed some seg faults I was experiencing using similar code. On Wed, Jun 6, 2012 at 12:11 AM, Denys Khanzhiyev xden...@gmail.comwrote: I definetelly shoot myself in my leg somewhere when i change code like that HandleScope scope; LocalValue js_field = LocalValue::New(Null()); js_field = String::New((const char*)(vary2-vary_string)); ... return scope.Close(js_field); to code like that HandleScope scope; LocalValue js_field = LocalValue::New(Null()); Buffer *slowBuffer = Buffer::New(vary2-vary_length); memcpy(Buffer::Data(slowBuffer), (const char*)(vary2-vary_string), vary2-vary_length); LocalObject globalObj = Context::GetCurrent()-Global(); LocalFunction bufferConstructor = LocalFunction::Cast(globalObj-Get(String::New(Buffer))); HandleValue constructorArgs[3] = { slowBuffer-handle_, Integer::New(vary2-vary_length), Integer::New(0) }; js_field = bufferConstructor-NewInstance(3, constructorArgs); ... return scope.Close(js_field); i.e. returns Buffer instead of String. Node strarts to fall with segmentation fault unconditionally. I call that method in a loop. The problem may appear after 100 iterations or after 1. The input data are same for both cases. Am I doing something wrong? 2012/6/5 Denys Khanzhiyev xden...@gmail.com gdb --args ./node_g ../node_firebird/issues/issue10.js GNU gdb (GDB) CentOS (7.0.1-42.el5.centos) Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i386-redhat-linux-gnu. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from /root/node/node_g...(no debugging symbols found)...done. Trying to catch segfault and all I get in backtrace Program received signal SIGSEGV, Segmentation fault. 0x578bbeaa in ?? () (gdb) backtrace #0 0x578bbeaa in ?? () #1 0x4aaeb361 in ?? () #2 0x478517a1 in ?? () #3 0x578bbe61 in ?? () #4 0x000c in ?? () #5 0x578acf46 in ?? () #6 0x in ?? () ]# ./node_g -v v0.6.13 built with ./configure --debug make any help? Thank you! -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: How would you serve 100,000 simultaneous comet requests with Node?
which node.js version was this benchmark run upon? I'm getting this output: /opt/node/bin/node client.js node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: Object #ClientRequest has no method 'finish' at addClient (/home/arq_msugano/bench/client.js:23:11) at Object.anonymous (/home/arq_msugano/bench/client.js:32:3) at Module._compile (module.js:402:26) at Object..js (module.js:408:10) at Module.load (module.js:334:31) at Function._load (module.js:293:12) at Array.anonymous (module.js:421:10) at EventEmitter._tickCallback (node.js:126:26) any thoughts? tya, On Monday, January 18, 2010 9:21:39 AM UTC-2, Felix Geisendoerfer wrote: A client asked me how many Comet connections node could handle, so I decided to give it try again today. To make a long story short, I was able to modify my client/server scripts so that node would no longer segfault, smoothly reaching 64510 parallel connections! http://gist.github.com/243632 There are two things I changed: a) Disabled the timeout for the underlaying tcp connections b) Always create 10 new connections in parallel and only attempt new connections when previous connections are established. Node still segfaults if I increase to a higher number of parallel connection starts. I was running my tests on a ridiculous High-Memory Quadruple Extra Large Ec2 instance with 68.4 GB memory (why not?) using Ubuntu 9.04. Here are some numbers: * From 0 to 64510 connections in 51 seconds * Minimal memory usage at 64510 connections: 364828 kb (5.66 kb / connection) * Peak memory usage at 64510 connections: 452732 kb (7.02 kb / connection) * Memory oscillation is due to v8's lazy garbage collection * There appear to be no noticeable memory leaks * The test happily ran for 2h 52m, I stopped it after that because nothing interesting seemed to happen anymore * During this time a total of 43281192 Hello\n messages were received by the 64510 clients * An average of 4194 messages / sec was received (ideally this value would have been closer to 6451, as each client was supposed to be sent a message every 10 sec) Conclusion: 64510 is the maximum of connections due to the available ports on the system, so the test had to stop there. However, I do think node could have a chance at the 1 million comet user record [1] set by Richard Jones with Erlang. But I decied to wait for the net2 branch to be ready before going through the trouble of setting this up. v8's occasional garbage collection does not seem to take longer than 1 second for most parts (otherwise the message / last-sec counter would drop below 0 several times in the logs, it only does so once after reaching 64510 connections). So here is hope it won't become a problem for high-performance apps. Response time variation seems big (as indicated by the oscillation in the message / last-sec counter), but this test is not really setup to measure it so I can't say much further about it. There is probably still a bug in node's connection handling that can cause a segfault if one tries to establish new connections too aggressively. But I challenge everybody to trigger this in a real- world scenario that is not a DOS attack. Either way, I'll retest that when the net2 branch is merged. Overall I am very impressed with node handling such a load, and especially the memory footprint seems very impressive. Oh, and I'd love to hear more thoughts on the topic! : ) [1] http://www.metabrew.com/article/a-million-user-comet-application-with-mochiweb-part-3/ --fg PS: My log files can be found here: http://gist.github.com/279936 On Dec 17 2009, 6:27 pm, Louis Santillan lpsan...@gmail.com wrote: This was recently covered on the v8-users list. http://groups.google.com/group/v8-users/browse_thread/thread/21283f61... The skinny: void V8::RunGC() { while( IdleNotification() ) ; } -L On Wed, Dec 16, 2009 at 11:47 PM, Stefan Scholl stefan.sch...@gmail.com wrote: On 27 Nov., 22:50, Ryan Dahl coldredle...@gmail.com wrote: On Fri, Nov 27, 2009 at 10:44 PM, Ricardo Tomasi ricardob...@gmail.com wrote: Worked out thememoryusage: 400mb for 20k clients (20k per connection) it goes up to roughly 1gb at 36.7kconnections(27k per client). Is it possible node is not completely freeing upmemoryfrom droppedconnections(lots during the process)? TheV8GCis pretty lazy - it likes to keep stuff around for a while. It's possible there is amemoryleak, but I doubt it. New to node.js. I was testing the simple Hello World script from the article on http://simonwillison.net/2009/Nov/23/node/with ApacheBench and was wondering the same. The memory usage was rising after each run of ApacheBench. Searched this group for memory leaks and most of them seem to be fixed. It's very unlikely that this simple
Re: [nodejs] value of _this_ within callback function ?
On Wed, Jun 6, 2012 at 1:53 PM, Jérémy Lal holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); this === global as of now[1]. [1] https://github.com/joyent/node/commit/463d6ba -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: How would you serve 100,000 simultaneous comet requests with Node?
On Jun 6, 1:28 pm, Marcel Mitsuto F. S. mits...@gmail.com wrote: which node.js version was this benchmark run upon? This thread is over 2 years old and node has changed a lot since then ;-) As for what node version? Maybe 0.1.x? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] value of _this_ within callback function ?
On Wed, Jun 6, 2012 at 3:55 PM, Ben Noordhuis i...@bnoordhuis.nl wrote: On Wed, Jun 6, 2012 at 1:53 PM, Jérémy Lal holi...@gmail.com wrote: Hi, require('fs').stat('file.txt', function(err, result) { console.log(this); // what is this ? }); this === global as of now[1]. [1] https://github.com/joyent/node/commit/463d6ba And of course, v8 is ES5.1 compliant, so you can just use Function.prototype.bind to bind an explicit scope of your choice Rick -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: How would you serve 100,000 simultaneous comet requests with Node?
That was wild times :D среда, 6 июня 2012 г., 23:59:00 UTC+4 пользователь mscdex написал: On Jun 6, 1:28 pm, Marcel Mitsuto F. S. mits...@gmail.com wrote: which node.js version was this benchmark run upon? This thread is over 2 years old and node has changed a lot since then ;-) As for what node version? Maybe 0.1.x? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
[nodejs] Re: How would you serve 100,000 simultaneous comet requests with Node?
I've made it to work now. I can spawn as many connections as the kernel TCP stack permits, but then node crashes when it gets to the limit. thanks! On Wednesday, June 6, 2012 5:38:59 PM UTC-3, Oleg Efimov (Sannis) wrote: That was wild times :D среда, 6 июня 2012 г., 23:59:00 UTC+4 пользователь mscdex написал: On Jun 6, 1:28 pm, Marcel Mitsuto F. S. mits...@gmail.com wrote: which node.js version was this benchmark run upon? This thread is over 2 years old and node has changed a lot since then ;-) As for what node version? Maybe 0.1.x? -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
Re: [nodejs] Re: How would you serve 100,000 simultaneous comet requests with Node?
On Thu, Jun 7, 2012 at 12:30 AM, Marcel Mitsuto F. S. mits...@gmail.com wrote: I can spawn as many connections as the kernel TCP stack permits, but then node crashes when it gets to the limit. Can you specify 'crash'? If you mean an EMFILE or ENFILE error, that's expected. If you mean 'segmentation fault' or something like that, that's a bug. -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups nodejs group. To post to this group, send email to nodejs@googlegroups.com To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en