nodejs / node-v0.x-archive Goto Github PK
View Code? Open in Web Editor NEWMoved to https://github.com/nodejs/node
Moved to https://github.com/nodejs/node
Implemented in one of my branches already, I think a lot of people would find this handy
to keep things clean and concise
node-v0.1.24> make test
Waf: Entering directory /Users/taf2/work/captico/node-v0.1.24/build' Waf: Leaving directory
/Users/taf2/work/captico/node-v0.1.24/build'
'build' finished successfully (0.254s)
python tools/test.py --mode=release
=== release test-tcp-many-clients ===
Path: mjsunit/test-tcp-many-clients
cccccccccccccccc################................
Command: build/default/node /Users/taf2/work/captico/node-v0.1.24/test/mjsunit/test-tcp-many-clients.js
--- TIMEOUT ---
make: *** [test] Error 1
Require function always cache, so it makes hot code swap very lousy. Would be interesting to have an alternative to this behavior so changes that you make on the code are deployed instantly.
it says
Assertion failed: (connection->port_ == NULL), function Connect, file ../src/net.cc, line 177.
This error only seems to appear when using posix.cat to read multiple files (or the same file multple times) using posix.cat. strace shows that it's hanging on epoll_wait.
var sys = require('sys');
var posix = require('posix');
var doc = '/etc/hosts';
for(var i=0;i<30;i++) {
posix.cat(doc).addCallback(
function(data) {
sys.puts("beep");
});
}
not sure about the rest but when you throw the error passed as an arg it does not
seem to propagate out for whatever reason.
This is needed personally because JSpec's assertion lookup routine catches an error then proceeds to try other possible fixture paths
For in process embeding, shared library version of node.js is very useful.
Node rev: e801f42
I'm getting a segfault in an app that makes few dozen http requests + serving few requests locally http://github.com/ncr/flickr_spy/commit/a1528373b0e454cfb9e2a640661f0502b730fb51
The segfault happens consistently when I connect 2 clients to my server (responses are streamed and take about 1-2 mins), when I connect only 1 client it works ok.
Here's the stacktrace fragment from node_g:
#
# Fatal error in /Users/ncr/dev/node/deps/v8/src/objects-inl.h, line 1585
# CHECK(object->IsProxy()) failed
#
==== Stack trace ============================================
Security context: 0x649205 #0#
2: flushMessageQueue(this=0x649281 #1#,connection=0x78bde1 >#2#,queue=0x78ee9d #3#)
3: /* anonymous */(this=0x78eee9 >#4#)
7: flush(this=0x78eee9 >#4#)
8: sendBody(this=0x78eee9 >#4#,chunk=0x1a69155 ,encoding=0x65a12d )
9: arguments adaptor frame: 1->2
10: /* anonymous */(this=0x78bdc5 >#5#,data=0x1a61219 #6#)
14: /* anonymous */(this=0x649281 #1#,user_ids=0x1a60999 #7#)
15: /* anonymous */(this=0x1814121 >#8#,data=0x1a5f0c9 >#9#)
16: arguments adaptor frame: 2->1
20: _respond(this=0x1814121 >#8#,type=0x65fbed ,data=0x1a5f0c9 >#9#,response=0x18140a9 >#10#)
21: /* anonymous */(this=0x18140a9 >#10#)
25: /* anonymous */(this=0x18006bd >#11#)
29: /* anonymous */(this=0x649281 #1#)
30: /* anonymous */(this=0x649281 #1#)
How can I help more (not being c coder for 10 years now)?
If we remove / disable those tests, then the tests should all pass for people compiling without Gnutls.
I'm not sure if this is really a node problem or a problem of v8, but there don't seem to be useful stack traces. For example, this is all I get for a syntax error:
testInsertedJSCode: SyntaxError: Unexpected string
node-waf
Error: Version mismatch: waf 1.5.9 <> wafadmin 1.5.10 (wafdir /Users/taf2/work/builds/bin/../lib/node)
version 0.2.4 and prior 0.2.3
Looks like the tests don't test url.parse(..., true) at all currently.
This crash is 100% repeatable for me, node 39ca935 on Linux openSUSE 11.1 x86_64:
Start helloworld.js, open a plain TCP socket to it, then close it. Boom - segfault.
I also noticed that the behaviour is the same (although the backtrace is slightly different) if I send some bytes before closing the socket.
No crash if I send data followed by a carriage-return before closing, even if the data is not a valid HTTP request. No subsequent crash on that running instance of helloworld.js even if I open and close sockets without sending any bytes.
6e4e228 uses AI_NUMERICSERV which doesn't exist on OSX:
[ 9/17] cxx: src/net.cc -> build/default/src/net_5.o
../src/net.cc:42: error: ‘AI_NUMERICSERV’ was not declared in this scope
../src/net.cc:49: error: ‘AI_NUMERICSERV’ was not declared in this scope
Build failed
-> task failed (err #1):
{task: cxx net.cc -> net_5.o}
make: *** [all] Error 1
Python 2.3.5
tiger-x86 0 ~/projects/node > ./waf build
Traceback (most recent call last):
File "./waf", line 127, in ?
Scripting.prepare(t, cwd, VERSION, wafdir)
File "/Users/ryan/projects/node/.waf-1.5.2-9bdedb7508a3a68a9e2e89a73bed6d5b/wafadmin/Scripting.py", line 12
prepare_impl(t,cwd,ver,wafdir)
File "/Users/ryan/projects/node/.waf-1.5.2-9bdedb7508a3a68a9e2e89a73bed6d5b/wafadmin/Scripting.py", line 11
main()
File "/Users/ryan/projects/node/.waf-1.5.2-9bdedb7508a3a68a9e2e89a73bed6d5b/wafadmin/Scripting.py", line 17
f(bld)
File "/Users/ryan/projects/node/wscript", line 142, in build
native_cc.clone("debug")
File "/Users/ryan/projects/node/.waf-1.5.2-9bdedb7508a3a68a9e2e89a73bed6d5b/wafadmin/TaskGen.py", line 150,
setattr(newobj,x,copy.copy(getattr(self,x)))
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy.py", line 108, in copy
return _reconstruct(x, rv, 0)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy.py", line 354, in _recons
y = callable(*args)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/copy_reg.py", line 92, in __ne
return cls.new(cls, *args)
TypeError: function() takes at least 2 arguments (0 given)
paths fail when using ~/foo etc
There's excessive memory growth over time. It seems like there is some leak but I cannot find anything with ./configure --debug and valgrind.
This issue was originally raised here:
http://groups.google.com/group/nodejs/browse_thread/thread/a8d1dfc2fd57a6d1
Although WAF was recently upgraded, bin/node-waf still reports version 1.5.9. This produces an error when the file is used to build some external module:
$ node-waf configure build
Error: Version mismatch: waf 1.5.9 <> wafadmin 1.5.10 (wafdir /usr/local/bin/../lib/node)
I've noticed that the testing framework that node uses is severly lacking documentation, and I feel that in any solid web platform should have good documentation on how to test it.
Server script is:
var http = require('http');
var server = http.createServer(function(req, res) {
res.sendHeader(200, {'Content-Type': 'text/plain'});
var counter = 5;
setTimeout(function() {
if (counter--) {
res.sendBody("HELLO....\n");
setTimeout(arguments.callee, 1000);
} else {
// should closes the connection
res.finish();
}
}, 1000);
});
server.listen(8000);
// should fetches 50 bytes of HELLOs
Executing wget 0.0.0.0:8000
should fetch 50 bytes of HELLOs from the server in approximately 5 seconds and then the connection should be closed.
I could not reproduce this behavior in pure node javascript so I resorted to using curl instead, anyway here's the server code:
require("http").createServer(function(req, resp) {
resp.sendHeader(200, { "Content-Type": "text/plain" });
resp.sendBody("ASDF");
resp.finish();
}).listen(8080);
executing curl -X ASDF 0.0.0.0:8080/abc --verbose
then proceeds to crash the server with the following message printed:
Segmentation fault
Here's the relevant lines from curl
> ASDF / HTTP/1.1
> User-Agent: curl/7.19.5 (i486-pc-linux-gnu) libcurl/7.19.5 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.15
> Host: 0.0.0.0:8080
> Accept: */*
>
* Empty reply from server
* Connection # 0 to host 0.0.0.0 left intact
curl: (52) Empty reply from server
Just having a sending a random arbitary method shouldn't be able to crash the server. I couldn't reproduce this in pure JS so didn't take the time to touch the test-http-malformed test file.
I'm using commit 3d24e11
Hope this helps.
I noticed a bug introduced in ry@3b8e47755a16c72d7b3509685a89c834c42a9342
whereby require("../foo") fails to work. The problem is that paths
like "foo/bar/../baz" get turned into "foobaz" instead of "foo/baz".
Discussion thread here: http://groups.google.com/group/nodejs/browse_thread/thread/34779f8c10098c5e
Isaac Schlueter kindly took my original fix (jasondavies@79efd868c460df001b2602e133e6f3f57c337356) and rewrote it to avoid using regexps and added tests: http://gist.github.com/260278
=== release test-tcp-pingpong ===
Path: mjsunit/test-tcp-pingpong
/home/boogie/work/ry-node-a623d763c189749ff8ce1f0cc25225be95686110/test/mjsunit/mjsunit.js:62: Failure: expected <1001> found <0>
throw new MjsUnitAssertionError(start + " expected <" + expected + "> found
^
socket(): Address family not supported by protocol
socket(): Address family not supported by protocol
Command: build/default/node /home/boogie/work/ry-node-a623d763c189749ff8ce1f0cc25225be95686110/test/mjsunit/test-tcp-pingpong.js
[00:05|% 100|+ 17|- 1]: Done
make: *** [test] Error 1
The helloworld.js works fine. But other project like node_chat or benchmarks/static_http_server.js
get this error:
Segmentation fault: 11 (core dumped)
$>uname -a
FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009 [email protected]:/usr/obj/usr/src/sys/GENERIC i386
$>node -v
0.1.20
$>gdb -c node.core
This GDB was configured as "i386-marcel-freebsd".
Core was generated by `node'.
Program terminated with signal 11, Segmentation fault.
#0 0x080c18cf in ?? ()
All other builds have been fine, updated my repo and tried to build the latest
source and I get this: http://gist.github.com/269668
MacOS 10.5.8
The following code works in 0.0.2 but not the latest commit
new node.http.Server(function (req, res) {
res.sendHeader(200, [["Content-Type", "text/plain"]]);
res.sendBody("Hello "+req.uri.queryKey.name);
res.finish();
}).listen(8000);
puts("Server running at http://127.0.0.1:8000/");
with request http://127.0.0.1:8000/?name=Connor you get
test.js:3: TypeError: Cannot read property 'name' of undefined
res.sendBody("Hello "+req.uri.queryKey.name);
^
timers do not block the main loop from exiting
var sys = require("sys");
setTimeout(2000, function() {
print("oeps")
});
This would be handy for my "kiwi" package management system since I want to take a rubygem-ish approach to the requiring so that it transparently supports modules already in the loadpath, as well as those installed by kiwi
Currently on OSX configure/building Node.js is failing.
$ ./configure
...
---- deps/udns ----
sh: ./configure: No such file or directory
Configuring deps/udns failed.
...
$ make
...
[7/21] ...
Build failed
-> task failed (err #2):
{task: deps/udns/libudns.a -> libudns.a}
[Dynamic Property] is not very descriptive in this context,
everyone knows them as getters and setters. Plus all
properties are "dynamic" so this does not really fit
I wrote a simple loop last night to test File I/O and noticed the following behavior. If I created a loop like so:
var times = [];
for (var i=0,j=251; i<j; i++) {
var t1 = Date.now();
var file = new node.fs.File();
file.open('test.log', 'a+');
file.write(i + ' ' + new Date() + ' Hello World!\n');
file.close();
times.push((Date.now() - t1));
}
'file' would contain only 250 new lines of text, while the array 'times' would show it's length to be 1000. The number of new lines added to the file seems fixed at 250. Setting the loop to 249 produced a times array with 249 items and a file with 249 new lines. Setting the loop to 251 produced a times array with 251 items and a file with 250 new lines.
My C++ is very poor, but my guess is that each event has a queue which is hard coded at 250 and my loop over flowed the queue.
Expected:
In a loop you should be able to write to files as much as you like. A web-server that is getting hit many times per second might overflow a 250 limit.
There currently seems to be no way of finding out the source of a request using nodes http server. Any chance of this being added, maybe req.remoteHost?
Thanks,
process.watchFile()
triggers twice for one file change. It doesn't happen on all changes (seems random) and only starts after repeated calls.
#!/usr/bin/env node
var sys = require('sys');
process.watchFile('foo', {interval: 1000}, function(curr,prev){
sys.puts("prev mtime: " + prev.mtime);
sys.puts("curr mtime: " + curr.mtime);
sys.puts("-------------------------");
});
on node 0.1.24, ubuntu
Currently if you don't set Transfer-Encoding or Content-Length then Transfer-Encoding gets set to chunked, it would be nice if I could set Transfer-Encoding to null or similar to force it not to be set.
While I was playing with this I also noticed if you set Content-Length-Something it matches Content-Length as being set, probably not going to cause any problems but not sure if there could be better behaviour?
http.parseUri("http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=")
parsedUri = {
"host": "114&hl=en&src=api&x=2&y=2&z=3&s=",
"user": "mt0.google.com/vt/lyrs=m",
"userInfo": "mt0.google.com/vt/lyrs=m",
"authority": "mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=",
"protocol": "http",
"source": "http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=",
"params": {}
}
Correct parse:
Addressable::URI.parse("http://mt0.google.com/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=").to_hash
# => {
:scheme=>"http",
:user=>nil,
:password=>nil,
:host=>"mt0.google.com",
:port=>nil,
:path=>"/vt/lyrs=m@114&hl=en&src=api&x=2&y=2&z=3&s=",
:query=>nil,
:fragment=>nil
}
Env: Mac 10.5
Example code:
var google = new node.http.Client(80, "google.com");
var req = google.get("/");
req.flush();
req.finish(function (res) {
puts("STATUS: " + res.statusCode);
puts("HEADERS: " + JSON.stringify(res.headers));
res.setBodyEncoding("utf8");
res.onBody = function (chunk) {
puts("BODY: " + chunk);
};
});
Running the http.Client never returns any data, just hangs and a bump in cpu usage is noted.
the errno is translated, exception is thrown, then exit.
if no errno is set, the buffer will be translated and subsequently free'd
I'm a bit confused by node's importing and requiring behavior. It's not clear why one must assign functions to a special 'exports' object. This could severely limit a library author's ability to reuse code between the server and client.
In my mind it would be more useful if importing behaved more similarly to Python's importing, where the assumption was that all files in a module are namespaced with the module's name if using 'require' ("import foo" in python) while everything is imported into the current scope if using 'import' ("from foo import *" in python). Of course, this is just in my mind and I don't understand the intricacies of what's happening under node's hood.
Whilst experimenting with node.js I (briefly) wanted to do the following:
posix.mkdir("someDir", 0755).wait();
This code seems to work fine when used alone but causes the node.js process to 'hang' when used within the callback of a call to e.g.:
posix.stat("/tmp").addCallback( function(stats) {
sys.puts("BEFORE");
posix.mkdir("/tmp/foo", 0755).wait();
sys.puts("AFTER");
});
Will output 'BEFORE' to the console and then just sit there. It has been suggested on the mailing list that I should raise this as an issue. I appreciate wait shouldn't be used (and it no longer is in my particular code) but its certainly worth drawing attention to this for others :)
NodeJS very fast. But only works on a single processor (one core)
It appears that the website & Changelog are offering a v0.1.25, which isn't available as a tag download.
Just tried building node.js @ 5b1a535 and had this problem:
Let me know if there's anything I can try to help troubleshoot.
Looks like an awesome project by the way :)
— ben_h
Test case:
var i = 0;
// prints get:
var obj = process.mixin({}, {
get a() { require('sys').puts('get'); return ++i; }, });
obj.a; // 1
obj.a; // 1, should be 2.
example:
Object.prototype.foo = 2;
var a = process.mixin({foo: 1}, {});
a.foo; // 2, should be 1
The message is
at #.Scaffold
at [object global].[anonymous]
at [object global].[anonymous]
./pubsub.js:83: SyntaxError: Unexpected token }
this.__onLoad = onLoad;};
Adding a ; or something similar fixes the issue.
Is this the intended behavior for ARGV[0] ?
cibook% which node
/opt/nodejs/bin/node
cibook% node main.js
/Users/atmos/p/irccat-nodejs/node /Users/atmos/p/irccat-nodejs/main.js port username channel
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.