platform/upstream/nodejs.git
10 years agohttp: Only send connection:keep-alive if necessary
isaacs [Sun, 18 Aug 2013 01:50:59 +0000 (18:50 -0700)]
http: Only send connection:keep-alive if necessary

In cases where the Agent has maxSockets=Infinity, and
keepAlive=false, there's no case where we won't immediately close the
connection after the response is completed.

Since we're going to close it anyway, send a `connection:close` header
rather than a `connection:keep-alive` header.  Still send the
`connection:keep-alive` if the agent will actually reuse the socket,
however.

Closes #5838

10 years agostream: return this from pause()/resume()
isaacs [Wed, 28 Aug 2013 01:59:58 +0000 (18:59 -0700)]
stream: return this from pause()/resume()

10 years agostream: make setEncoding chainable
Julian Gruber [Mon, 19 Aug 2013 17:14:42 +0000 (13:14 -0400)]
stream: make setEncoding chainable

10 years agorepl: Simplify paren wrap, continuation-detection
isaacs [Thu, 29 Aug 2013 21:48:24 +0000 (14:48 -0700)]
repl: Simplify paren wrap, continuation-detection

This simplifies the logic that was in isSyntaxError, as well as the
choice to wrap command input in parens to coerce to an expression
statement.

1. Rather than a growing blacklist of allowed-to-throw syntax errors,
just sniff for the one we really care about ("Unexpected end of input")
and let all the others pass through.

2. Wrapping {a:1} in parens makes sense, because blocks and line labels
are silly and confusing and should not be in JavaScript at all.
However, wrapping functions and other types of programs in parens is
weird and required yet *more* hacking to work around.  By only wrapping
statements that start with { and end with }, we can handle the confusing
use-case, without having to then do extra work for functions and other
cases.

This also fixes the repl wart where `console.log)(` works in the repl,
but only by virtue of the fact that it's wrapped in parens first, as
well as potential side effects of double-running the commands, such as:

    > x = 1
    1
    > eval('x++; throw new SyntaxError("e")')
    ... ^C
    > x
    3

10 years agorepl: treat "Assignment to const" as syntax error
Nathan Rajlich [Tue, 27 Aug 2013 15:57:16 +0000 (08:57 -0700)]
repl: treat "Assignment to const" as syntax error

Adding a new `repl-harmony` test file here because adding the
`--use_strict --harmony` flags on the main repl test file was causing
lots of unrelated failures, due to global variable assignments and
things like that. This new test file is based off of the original
repl.js test file, but has a lot of the tests stripped out. A test case
for this commit is included though.

Fixes #6132.

10 years agorepl: Catch syntax errors better
isaacs [Wed, 28 Aug 2013 01:53:39 +0000 (18:53 -0700)]
repl: Catch syntax errors better

Replace the growing list of 'isSyntaxError' whackamole conditions with a
smarter approach.  This creates a vm Script object *first*, which will
parse the code and raise a SyntaxError right away.

We still do need the test function, but only because strict mode syntax
errors are not recoverable, and should be raised right away.  Really, we
should probably *only* continue on "unexpected end of input" SyntaxErrors.

Also fixes a very difficult-to-test nit where the '...' indentation is
not properly cleared when you ^C out of a syntax error.

Closes #6093

10 years agouv: upgrade to v0.11.13
Ben Noordhuis [Wed, 4 Sep 2013 12:46:35 +0000 (14:46 +0200)]
uv: upgrade to v0.11.13

This commit changes src/tcp_wrap.cc and src/udp_wrap.cc just enough to
get by (i.e. to compile and function correctly.)

The new libuv API allows for more cleanup and deduplication but I'm
saving that for another day.

10 years agobuild: remove unused Carbon dependency
Ben Noordhuis [Wed, 4 Sep 2013 07:55:57 +0000 (09:55 +0200)]
build: remove unused Carbon dependency

Libuv as of joyent/libuv@d48168a no longer has link-time dependencies
on the Carbon framework or any other frameworks.

10 years agostring_bytes: use extern for length and write utf8
Trevor Norris [Tue, 3 Sep 2013 11:04:26 +0000 (04:04 -0700)]
string_bytes: use extern for length and write utf8

If the string is external then the length can be quickly retrieved. This
is especially faster for large strings that are being treated as UTF8.
Also, if the string is external then there's no need for a full
String::WriteUtf8 operation. A simple memcpy will do.

10 years agoprocess: Add internal _rawDebug() method
isaacs [Wed, 21 Aug 2013 22:36:50 +0000 (15:36 -0700)]
process: Add internal _rawDebug() method

This is useful when we need to push some debugging messages out to
stderr, without going through the Writable class, or triggering any kind
of nextTick or callback behavior.

10 years agosrc: Remove outdated comment re assert()
isaacs [Wed, 21 Aug 2013 22:39:14 +0000 (15:39 -0700)]
src: Remove outdated comment re assert()

It's a normal function now, not a macro.

10 years agouv: upgrade to v0.11.12
Ben Noordhuis [Mon, 2 Sep 2013 22:42:59 +0000 (00:42 +0200)]
uv: upgrade to v0.11.12

* upgrade deps/uv/ to v0.11.12.
* update files in src/ after a libuv API change.

10 years agosrc: clean up CLI argument parser
Ben Noordhuis [Mon, 2 Sep 2013 14:42:01 +0000 (16:42 +0200)]
src: clean up CLI argument parser

* Exit with an error message when the option is not a node or V8 option.

* Remove the option_end_index global.  Needs to happen anyway for
  the multi-context work, might as well land it in master now.

* Add a smidgen of const-correctness.

* Pay off a few years of accrued technical debt.

10 years agotest: don't use --max-stack-size=0
Ben Noordhuis [Mon, 2 Sep 2013 17:10:36 +0000 (19:10 +0200)]
test: don't use --max-stack-size=0

--max-stack-size was removed in 3a87b31, use --stack-size instead.
What's more, a zero length stack will likely crash the process.

10 years agotest: speed up simple/test-fs-watch
Ben Noordhuis [Sun, 1 Sep 2013 12:47:25 +0000 (14:47 +0200)]
test: speed up simple/test-fs-watch

Don't wait a full second before starting the watcher, 10 ms ought to be
more than enough time.  Reduces running time from 1250 ms to 250 ms on
my system.

10 years agoMerge remote-tracking branch 'ry/v0.10'
isaacs [Sun, 1 Sep 2013 00:58:44 +0000 (17:58 -0700)]
Merge remote-tracking branch 'ry/v0.10'

10 years agobenchmark: Fix execArgv handling
isaacs [Sun, 1 Sep 2013 00:58:17 +0000 (17:58 -0700)]
benchmark: Fix execArgv handling

Bug in 01f3b46 causes the same benchmark to be run repeatedly.

Not so useful for the compare scripts.

10 years agoMerge remote-tracking branch 'ry/v0.10'
isaacs [Sat, 31 Aug 2013 18:29:51 +0000 (11:29 -0700)]
Merge remote-tracking branch 'ry/v0.10'

10 years agobenchmark: Support passing v8 flags to benchmarks
isaacs [Sat, 31 Aug 2013 05:39:06 +0000 (22:39 -0700)]
benchmark: Support passing v8 flags to benchmarks

The better to test --use-strict effects on performance.

(Spoiler: it has no measurable effect on performance.)

10 years agoRevert "src: call uv_loop_delete() on exit in debug mode"
Ben Noordhuis [Fri, 30 Aug 2013 21:28:22 +0000 (23:28 +0200)]
Revert "src: call uv_loop_delete() on exit in debug mode"

Don't call uv_loop_delete() until we've figured out a way to gracefully
close open handles.  See also commit 4915884 and its subsequent revert
in commit 980cbd5.

This reverts commit 556b890ad91780c52c77dccaddcf69beb8184e27.

10 years agoRevert "src: close libuv handles on exit"
Ben Noordhuis [Fri, 30 Aug 2013 21:21:05 +0000 (23:21 +0200)]
Revert "src: close libuv handles on exit"

This change is not entirely ready for prime time: it's making ~50 tests
fail on Windows, mostly due to timeouts.  It's up for debate who is
at fault here: node.js or libuv.

It does however expose a libuv bug on OS X, where the event loop
sometimes gets stuck in uv__io_poll() when there is a single
UV_SHUTDOWN request left in the queue.  Needs further investigation.

This reverts commit 4915884da69814bd4daab22393919a628c9ecf23.

10 years agotest: move smalloc segfault tests to pummel
Trevor Norris [Fri, 30 Aug 2013 20:55:53 +0000 (13:55 -0700)]
test: move smalloc segfault tests to pummel

These tests take a while to complete, and the issue only potentially
appears under heavy load.

10 years agosrc: close libuv handles on exit
Ben Noordhuis [Thu, 29 Aug 2013 09:39:37 +0000 (11:39 +0200)]
src: close libuv handles on exit

Commit 556b890 added a call to uv_loop_delete() with the intent of
catching handle lifecycle bugs.  It worked because it exposed one:

    process.on('exit', function() {
      console.log('bye');  // Asserts.
    });

When run, it asserts with the following message:

    Assertion failed: (!uv__has_active_reqs(loop)), function
    uv__loop_delete, file ../deps/uv/src/unix/loop.c, line 150.

That's because libuv as of joyent/libuv@3f2d4d5 checks that there are
no in-flight requests when the event loop is destroyed.  In the test
case above, the write request for the string hasn't completed yet by
the time node.js exits: the string itself has most likely been written
but libuv hasn't had the opportunity to return the write request to
node.js.

That's why this commit adds a cleanup step right before exit where it
explicitly closes all open handles, then waits until the event loop
exits naturally.

Named pipes (UNIX domain sockets) are shut down first in order to flush
pending write requests.  Should go some way towards fixing the Windows
issue where output on stdout/stderr sometimes gets truncated.

Fixes joyent/libuv#911.

10 years agouv: upgrade to v0.11.11
Bert Belder [Thu, 29 Aug 2013 13:04:27 +0000 (15:04 +0200)]
uv: upgrade to v0.11.11

10 years agosrc: remove unused Persistent<FunctionTemplate>
Ben Noordhuis [Thu, 29 Aug 2013 12:28:24 +0000 (14:28 +0200)]
src: remove unused Persistent<FunctionTemplate>

10 years agocrypto: remove NodeBIO::GetMethod()
Ben Noordhuis [Thu, 29 Aug 2013 12:19:27 +0000 (14:19 +0200)]
crypto: remove NodeBIO::GetMethod()

Remove NodeBIO::GetMethod() and replace calls to BIO_new() with calls
to the new NodeBIO::New() function.

This commit basically reshuffles some code in order to make it explicit
that the NodeBIO BIO_METHOD is const.

10 years agocrypto: make root_cert_store variable extern
Ben Noordhuis [Thu, 29 Aug 2013 12:05:42 +0000 (14:05 +0200)]
crypto: make root_cert_store variable extern

Before this commit it was declared static (in a header file!), meaning
it got duplicated in every file that includes it.

A few duplicated pointers is not the end of the world but it introduces
a lot of potential for confusion because root_cert_store in file A is
not the root_cert_store in file B.

Moral of the story: don't declare static variables in header files.

10 years agocrypto: remove misleading comment
Ben Noordhuis [Thu, 29 Aug 2013 12:02:11 +0000 (14:02 +0200)]
crypto: remove misleading comment

10 years agocrypto: make error buffer non-static
Ben Noordhuis [Thu, 29 Aug 2013 11:57:29 +0000 (13:57 +0200)]
crypto: make error buffer non-static

Doesn't matter now but it will if/when we have support for multiple
threads.

10 years agovm: document vm2's changes.
Domenic Denicola [Sat, 24 Aug 2013 23:46:31 +0000 (19:46 -0400)]
vm: document vm2's changes.

- The caveats no longer apply.
- Document options arguments, including `displayErrors` and the
  different things it means in each place.
- Re-did examples to be more on point, e.g. `runInContext` example
  runs multiple scripts in the same context.
- Documented how `vm.createContext`s meaning has substantially changed,
  and is now more of a "contextifier" than a "creator."
- Reordered vm functions to be readable in order; the concept of
  contextifying needs to come before `runInContext` and
  `runInNewContext`.
- Documented new `vm.isContext`.
- Documented the `vm.Script` constructor, instead of `createScript`,
  since factory methods are silly and we wanted to document the class's
  methods anyway.
- Documented `script.runInContext`.
- Change stability to stable, if I may be so bold.

10 years agovm: update API to use options argument
Domenic Denicola [Sat, 24 Aug 2013 22:53:24 +0000 (18:53 -0400)]
vm: update API to use options argument

Passing a filename is still supported in place of certain options
arguments, for backward-compatibility, but timeout and display-errors
are not translated since those were undocumented.

Also managed to eliminate an extra stack trace line by not calling
through the `createScript` export.

Added a few message tests to show how `displayErrors` works.

10 years agopipe_wrap: squelch integer type conversion warning
Bert Belder [Wed, 28 Aug 2013 21:35:43 +0000 (23:35 +0200)]
pipe_wrap: squelch integer type conversion warning

10 years agotimer_wrap: Timer.now always update loop time
Timothy J Fontaine [Wed, 28 Aug 2013 18:29:33 +0000 (11:29 -0700)]
timer_wrap: Timer.now always update loop time

In `Timer.now` always update the loop time by calling uv_update_time.
Previously we were trying to cache the loop time to prevent extra
syscalls. While a noble goal, it can cause timers to fire early in
certain circumstances. Especially seen in cpu bound work loads or work
loads with synchronous file operations.

10 years agoMerge remote-tracking branch 'ry/v0.10'
isaacs [Wed, 28 Aug 2013 17:11:17 +0000 (10:11 -0700)]
Merge remote-tracking branch 'ry/v0.10'

Conflicts:
AUTHORS
ChangeLog
deps/uv/ChangeLog
deps/uv/include/uv-darwin.h
deps/uv/src/unix/darwin.c
deps/uv/src/unix/fsevents.c
deps/uv/src/version.c
lib/_stream_writable.js
src/node_version.h

10 years agostream: check _events before _events.error
isaacs [Wed, 28 Aug 2013 16:35:36 +0000 (09:35 -0700)]
stream: check _events before _events.error

This fixes the regression introduced by 5458079, which breaks the
net/net-pipe benchmark script.

Closes #6145

10 years agocrypto: make randomBytes/pbkdf2 cbs domain aware
Ben Noordhuis [Tue, 27 Aug 2013 19:11:13 +0000 (21:11 +0200)]
crypto: make randomBytes/pbkdf2 cbs domain aware

Make the crypto.randomBytes() and crypto.pbkdf2() callback functions
run inside the current domain (if any.)

Fixes #3965.

10 years agovm: add isContext; prevent double-contextifying
Domenic Denicola [Sat, 24 Aug 2013 19:45:02 +0000 (15:45 -0400)]
vm: add isContext; prevent double-contextifying

Previously, calling `vm.createContext(o)` repeatedly on the same `o`
would cause new C++ `ContextifyContext`s to be created and stored on
`o`, while the previous resident went off into leaked-memory limbo.
Now, repeatedly trying to contextify a sandbox will do nothing after
the first time.

To detect this, an independently-useful `vm.isContext(sandbox)` export
was added.

10 years agovm: use MakeWeak to fix leaking contexts
Domenic Denicola [Sat, 24 Aug 2013 01:33:16 +0000 (21:33 -0400)]
vm: use MakeWeak to fix leaking contexts

This is always something you should do when using `SetHiddenValue`,
apparently. Fixes #6115. Thanks @tjfontaine for the tips.

10 years agovm: rip out ObjectWrap from ContextifyContext
Domenic Denicola [Sat, 24 Aug 2013 01:17:15 +0000 (21:17 -0400)]
vm: rip out ObjectWrap from ContextifyContext

This was a remnant of the original Contextify code, wherein
ContextifyContext was a user-exposed object. In vm, it is not, so all
of the ObjectWrap and function-template stuff for the ContextifyContext
constructor is now unnecessary.

10 years agodoc: Adjust util stability index to 'API Frozen'
isaacs [Wed, 28 Aug 2013 02:52:09 +0000 (19:52 -0700)]
doc: Adjust util stability index to 'API Frozen'

Closes #6087

10 years agodoc: Adjust util stability index to 'API Frozen'
isaacs [Wed, 28 Aug 2013 02:52:09 +0000 (19:52 -0700)]
doc: Adjust util stability index to 'API Frozen'

Closes #6087

10 years agodoc: mark repl as stable
isaacs [Wed, 28 Aug 2013 01:09:26 +0000 (18:09 -0700)]
doc: mark repl as stable

Closes #6090

10 years agostream: change default hwm for objectMode to 16
Mathias Buus [Thu, 22 Aug 2013 17:58:27 +0000 (19:58 +0200)]
stream: change default hwm for objectMode to 16

10 years agochild_process: Avoid extra copy for string stdio
isaacs [Wed, 28 Aug 2013 00:28:27 +0000 (17:28 -0700)]
child_process: Avoid extra copy for string stdio

There's no need to create a new Buffer instance if we're just going to
immediately call toString() at the end anyway.  Better to create a
string up front, and setEncoding() on the streams, and do a string
concatenation instead.

10 years agochild_process: Callback with Buffers from exec
Seth Fitzsimmons [Sat, 13 Jul 2013 23:34:52 +0000 (16:34 -0700)]
child_process: Callback with Buffers from exec

Only return strings when encoding is not null.

10 years agov8: upgrade to 3.20.17
Trevor Norris [Tue, 27 Aug 2013 22:18:12 +0000 (15:18 -0700)]
v8: upgrade to 3.20.17

10 years agostream: Pass 'buffer' encoding to decoded writables
isaacs [Tue, 27 Aug 2013 21:53:06 +0000 (14:53 -0700)]
stream: Pass 'buffer' encoding to decoded writables

Since the encoding is no longer relevant once it is decoded to a Buffer,
it is confusing and incorrect to pass the encoding as 'utf8' or whatever
in those cases.

Closes #6119

10 years agodomains: deprecate domain.dispose().
Forrest L Norvell [Thu, 14 Mar 2013 21:11:15 +0000 (14:11 -0700)]
domains: deprecate domain.dispose().

Follows @isaacs's recommendations in joyent/node#5018. Includes some
updates to documentation but not examples.

Conflicts:
lib/domain.js

10 years agofs: Expose birthtime on stat objects
isaacs [Tue, 27 Aug 2013 17:35:14 +0000 (10:35 -0700)]
fs: Expose birthtime on stat objects

Just do the best we can with whatever libuv gives us.

Also, document the semantics of `ctime` and the compatibility with
Windows.

10 years agodoc: Small update of readme for Windows users
Jay Beavers [Mon, 8 Apr 2013 22:33:49 +0000 (15:33 -0700)]
doc: Small update of readme for Windows users

10 years agolib: Add missing copyright notices
isaacs [Tue, 27 Aug 2013 02:14:42 +0000 (19:14 -0700)]
lib: Add missing copyright notices

10 years agosrc: remove two pointless globals from node.cc
Ben Noordhuis [Tue, 27 Aug 2013 14:14:45 +0000 (16:14 +0200)]
src: remove two pointless globals from node.cc

De-globalize use_npn and use_sni, they're only used in GetFeatures().

10 years agosrc: call uv_loop_delete() on exit in debug mode
Ben Noordhuis [Tue, 27 Aug 2013 12:47:46 +0000 (14:47 +0200)]
src: call uv_loop_delete() on exit in debug mode

Should make tracing with valgrind a little easier on the eye and
possibly help expose libuv handle lifecycle issues.

10 years agosrc: remove --max-stack-size option
Ben Noordhuis [Tue, 27 Aug 2013 12:09:36 +0000 (14:09 +0200)]
src: remove --max-stack-size option

Ad-hoc duplicate of V8's --stack-size option.  Superfluous in other
words.  Remove it.

10 years agocares_wrap: drop UV_HANDLE_FIELDS from ares_task_t
Ben Noordhuis [Tue, 27 Aug 2013 11:20:39 +0000 (13:20 +0200)]
cares_wrap: drop UV_HANDLE_FIELDS from ares_task_t

UV_HANDLE_FIELDS is a libuv implementation detail.  The ares_task_t
struct only uses the uv_loop_t* field so be explicit about that.

10 years agosrc: fix up unused/unordered imports
Ben Noordhuis [Mon, 26 Aug 2013 22:13:50 +0000 (00:13 +0200)]
src: fix up unused/unordered imports

10 years agobuffer: fix assert fail from JS API
Trevor Norris [Mon, 26 Aug 2013 10:26:31 +0000 (03:26 -0700)]
buffer: fix assert fail from JS API

Length arguments passed to SlowBuffer were coerced to Int32, not Uint32,
so passing a negative number would throw the following:

node: ../src/smalloc.cc:244: void node::smalloc::Alloc(): Assertion `length <= kMaxLength' failed.
Aborted (core dumped)

That has been fixed by coercing to Uint32 and comparing the value
against kMaxLength.

10 years agobuffer: add NativeBuffer API
Trevor Norris [Mon, 26 Aug 2013 10:20:23 +0000 (03:20 -0700)]
buffer: add NativeBuffer API

Due to a lot of the util.is* checks there was much unnecessary overhead
for the most common use case of Buffer. Which is creating a new Buffer
instance for data from incoming I/O. NativeBuffer is a simple way to
bypass all the unneeded checks and simply hand back a Buffer instance
while setting the length.

10 years agosrc: remove pointless node_os.h header file
Ben Noordhuis [Mon, 26 Aug 2013 13:13:35 +0000 (15:13 +0200)]
src: remove pointless node_os.h header file

src/node_os.cc doesn't export anything that's used elsewhere. Remove it.

10 years agoprocess_wrap: don't coerce process exit code to int32_t
Bert Belder [Sun, 25 Aug 2013 16:44:57 +0000 (18:44 +0200)]
process_wrap: don't coerce process exit code to int32_t

On windows process exit codes can be greater than INT32_MAX. This used
to be not much of a problem - greater values would just come out
negative. However since ca9eb71 a negative result value indicates that
uv_spawn() has failed, so this is no longer acceptable.

10 years agouv: upgrade to v0.11.10
Bert Belder [Sat, 24 Aug 2013 17:47:45 +0000 (19:47 +0200)]
uv: upgrade to v0.11.10

10 years agodomain: move error handling directly into instance
Trevor Norris [Wed, 21 Aug 2013 23:12:17 +0000 (16:12 -0700)]
domain: move error handling directly into instance

Instead of doing all the domain handling in core, allow the domain to
set an error handler that'll take care of it all. This way the domain
error handling can be abstracted enough for any user to use it.

10 years agoprocess_wrap: update after libuv api change
Bert Belder [Fri, 23 Aug 2013 17:08:49 +0000 (19:08 +0200)]
process_wrap: update after libuv api change

The `exit_code` argument for the `ProcessWrap::OnExit` callback changed
from int to int64_t.

10 years agouv: upgrade to v0.11.9
Bert Belder [Fri, 23 Aug 2013 17:04:27 +0000 (19:04 +0200)]
uv: upgrade to v0.11.9

10 years agouv: update to v0.10.15
Bert Belder [Fri, 23 Aug 2013 17:02:14 +0000 (19:02 +0200)]
uv: update to v0.10.15

10 years agovm: fix Persistent<Context> leak
Ben Noordhuis [Fri, 23 Aug 2013 00:01:29 +0000 (02:01 +0200)]
vm: fix Persistent<Context> leak

10 years agovm: remove unnecessary Persistent<FunctionTemplate>
Ben Noordhuis [Fri, 23 Aug 2013 12:29:57 +0000 (14:29 +0200)]
vm: remove unnecessary Persistent<FunctionTemplate>

10 years agobuffer: fix regression in Buffer(buf) constructor
Ben Noordhuis [Fri, 23 Aug 2013 10:00:28 +0000 (12:00 +0200)]
buffer: fix regression in Buffer(buf) constructor

Commit 3a2f273b got the source and the target wrong when copying over
the data. Fix that and add a regression test.

Fixes #6111.

10 years agoutil: pass opts to custom inspect functions
Timothy J Fontaine [Thu, 22 Aug 2013 01:38:23 +0000 (18:38 -0700)]
util: pass opts to custom inspect functions

Objects with custom inpsect functions should get the options that were
passed to `util.inspect()`

fixes #5822
fixes #6098

10 years agobuffer: fix inspect throw if slice length too long
Trevor Norris [Thu, 22 Aug 2013 05:18:20 +0000 (22:18 -0700)]
buffer: fix inspect throw if slice length too long

All the Buffer#{ascii,hex,etc.}Slice() methods are intentionally strict
to alert if a Buffer instance was attempting to be accessed out of
bounds. Buffer#toString() is the more user friendly way of accessing the
data, and will coerce values to their min/max on overflow.

10 years agobuffer: adhere to INSPECT_MAX_BYTES
Timothy J Fontaine [Thu, 22 Aug 2013 01:17:11 +0000 (18:17 -0700)]
buffer: adhere to INSPECT_MAX_BYTES

10 years agovm: Put back display_errors flag
isaacs [Thu, 22 Aug 2013 00:19:41 +0000 (17:19 -0700)]
vm: Put back display_errors flag

This is an important part of the repl use-case.

TODO: The arg parsing in vm.runIn*Context() is rather wonky.
It would be good to move more of that into the Script class,
and/or an options object.

10 years agotools: script release steps after jenkins build
Timothy J Fontaine [Wed, 21 Aug 2013 23:59:15 +0000 (16:59 -0700)]
tools: script release steps after jenkins build

10 years agotools: script to report [un]stable build
Timothy J Fontaine [Wed, 21 Aug 2013 23:55:27 +0000 (16:55 -0700)]
tools: script to report [un]stable build

10 years agoblog: Post for v0.10.17
Timothy J Fontaine [Wed, 21 Aug 2013 23:38:30 +0000 (16:38 -0700)]
blog: Post for v0.10.17

10 years agoNow working on 0.10.18
Timothy J Fontaine [Wed, 21 Aug 2013 23:37:43 +0000 (16:37 -0700)]
Now working on 0.10.18

10 years agoMerge branch 'v0.10.17-release' into v0.10
Timothy J Fontaine [Wed, 21 Aug 2013 23:37:31 +0000 (16:37 -0700)]
Merge branch 'v0.10.17-release' into v0.10

10 years agovm, core, module: re-do vm to fix known issues
Domenic Denicola [Sat, 27 Jul 2013 04:34:12 +0000 (00:34 -0400)]
vm, core, module: re-do vm to fix known issues

As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.

Functionally, this fixes #3042. In particular:

- A context is now indistinguishable from the object it is based on
  (the "sandbox"). A context is simply a sandbox that has been marked
  by the vm module, via `vm.createContext`, with special internal
  information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
  immediately visible to all code that can access that context, both
  inside and outside the virtual machine.

This commit also smooths over the API very slightly:

- Parameter defaults are now uniformly triggered via `undefined`, per
  ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
  the conflation of `vm.Script` with `vm` itself, and the fact that
  `Script` instances also had all static `vm` methods. The API is now
  exactly as documented (although arguably the existence of the
  `vm.Script` export is not yet documented, just the `Script` class
  itself).

In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.

The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:

- ContextifyScript(code, [filename]), with methods:
  - runInThisContext()
  - runInContext(sandbox, [timeout])
- makeContext(sandbox)

From this, the vm.js file builds the entire documented vm module API.

node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.

The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.

New tests were also added, of course, demonstrating the new
capabilities and fixes.

[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: https://github.com/kkoopa/contextify/blob/bf123f3ef960f0943d1e30bda02e3163a004e964/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120

10 years ago2013.08.21, Version 0.10.17 (Stable) v0.10.17
Timothy J Fontaine [Wed, 21 Aug 2013 22:00:56 +0000 (15:00 -0700)]
2013.08.21, Version 0.10.17 (Stable)

* uv: Upgrade v0.10.14

* http_parser: Do not accept PUN/GEM methods as PUT/GET (Chris Dickinson)

* tls: fix assertion when ssl is destroyed at read (Fedor Indutny)

* stream: Throw on 'error' if listeners removed (isaacs)

* dgram: fix assertion on bad send() arguments (Ben Noordhuis)

* readline: pause stdin before turning off terminal raw mode (Daniel Chatfield)

10 years agouv: Upgrade v0.10.14
Timothy J Fontaine [Wed, 21 Aug 2013 21:44:20 +0000 (14:44 -0700)]
uv: Upgrade v0.10.14

10 years agoblog: v0.11.6
Timothy J Fontaine [Wed, 21 Aug 2013 21:26:32 +0000 (14:26 -0700)]
blog: v0.11.6

10 years agoNow working on 0.11.7
Timothy J Fontaine [Wed, 21 Aug 2013 21:16:46 +0000 (14:16 -0700)]
Now working on 0.11.7

10 years agoMerge branch 'v0.11.6-release'
Timothy J Fontaine [Wed, 21 Aug 2013 21:16:29 +0000 (14:16 -0700)]
Merge branch 'v0.11.6-release'

10 years ago2013.08.21, Version 0.11.6 (Unstable) v0.11.6
Timothy J Fontaine [Wed, 21 Aug 2013 20:20:50 +0000 (13:20 -0700)]
2013.08.21, Version 0.11.6 (Unstable)

* uv: Upgrade to v0.11.8

* v8: upgrade v8 to 3.20.14.1

* build: disable SSLv2 by default (Ben Noordhuis)

* build: don't auto-destroy existing configuration (Ben Noordhuis)

* crypto: add TLS 1.1 and 1.2 to secureProtocol list (Matthias Bartelmeß)

* crypto: fix memory leak in randomBytes() error path (Ben Noordhuis)

* dgram: don't call into js when send cb is omitted (Ben Noordhuis)

* dgram: fix regression in string argument handling (Ben Noordhuis)

* domains: performance improvements (Trevor Norris)

* events: EventEmitter = require('events') (Jake Verbaten)

* http: Add write()/end() callbacks (isaacs)

* http: Consistent 'finish' event semantics (isaacs)

* http: Prefer 'binary' over 'ascii' (isaacs)

* http: Support legacy agent.addRequest API (isaacs)

* http: Write hex/base64 chunks properly (isaacs)

* http: add agent.maxFreeSockets option (isaacs)

* http: provide access to raw headers/trailers (isaacs)

* http: removed headers stay removed (James Halliday)

* http,timers: improve callback performance (Ben Noordhuis)

* net: family option in net.connect (Vsevolod Strukchinsky)

* readline: pause stdin before turning off terminal raw mode (Daniel Chatfield)

* smalloc: allow different external array types (Trevor Norris)

* smalloc: expose ExternalArraySize (Trevor Norris)

* stream: Short-circuit buffer pushes when flowing (isaacs)

* tls: handle errors on socket before releasing it (Fedor Indutny)

* util: fix isPrimitive check (Trevor Norris)

* util: isObject should always return boolean (Trevor Norris)

10 years agouv: Upgrade to v0.11.8
Timothy J Fontaine [Wed, 21 Aug 2013 18:15:21 +0000 (11:15 -0700)]
uv: Upgrade to v0.11.8

10 years agodoc: Mention python dep in downloads page
isaacs [Wed, 21 Aug 2013 18:11:02 +0000 (11:11 -0700)]
doc: Mention python dep in downloads page

Closes #3604

10 years agotest: net-GH-5504 child env needs NODE_COMMON_PORT
Timothy J Fontaine [Wed, 21 Aug 2013 17:51:42 +0000 (10:51 -0700)]
test: net-GH-5504 child env needs NODE_COMMON_PORT

10 years agoMerge remote-tracking branch 'ry/v0.10'
isaacs [Wed, 21 Aug 2013 16:40:10 +0000 (09:40 -0700)]
Merge remote-tracking branch 'ry/v0.10'

Conflicts:
lib/tls.js

10 years agotest: fix test failure on linux after edd2fcc
Fedor Indutny [Wed, 21 Aug 2013 08:33:09 +0000 (12:33 +0400)]
test: fix test failure on linux after edd2fcc

10 years agodeps: upgrade http_parser to 303c4e4
Ben Noordhuis [Wed, 21 Aug 2013 01:33:20 +0000 (03:33 +0200)]
deps: upgrade http_parser to 303c4e4

Upgrade to joyent/http-parser@303c4e4. Changes:

  * Do not accept PUN/GEM methods as PUT/GET.
  * Further request method check strengthening.

10 years agotls: fix assertion when ssl is destroyed at read
Fedor Indutny [Wed, 21 Aug 2013 11:58:33 +0000 (15:58 +0400)]
tls: fix assertion when ssl is destroyed at read

`maybeInitFinished()` can emit the 'secure' event which
in turn destroys the connection in case of authentication
failure and sets `this.pair.ssl` to `null`.

If such condition appeared after non-empty read - loop will continue
and `clearOut` will be called on `null` object instead of
`crypto::Connection` instance. Resulting in the following assertion:

    ERROR: Error: Hostname/IP doesn't match certificate's altnames
    Assertion failed: handle->InternalFieldCount() > 0

fix #5756

10 years agosmalloc: consistent-ify syntax
Trevor Norris [Tue, 20 Aug 2013 17:55:42 +0000 (10:55 -0700)]
smalloc: consistent-ify syntax

Small syntax fixes of variable renaming and argument alignment.

10 years agosmalloc: length is byte size, not array length
Trevor Norris [Tue, 20 Aug 2013 17:30:40 +0000 (10:30 -0700)]
smalloc: length is byte size, not array length

The C++ API has been changed so the passed length is the byte size of
the data, not the length of the array.

This was done so users need to explicitly define how much memory they
want allocated.

10 years agosmalloc: expose ExternalArraySize
Trevor Norris [Tue, 20 Aug 2013 17:12:29 +0000 (10:12 -0700)]
smalloc: expose ExternalArraySize

Useful to correctly determine the byte size of the external memory that
needs to be allocated for an external array.

10 years agoutil: isObject should always return boolean
Trevor Norris [Tue, 20 Aug 2013 18:05:36 +0000 (11:05 -0700)]
util: isObject should always return boolean

Fix small bug where isObject would return the original object instead of
true.

10 years agonet: family option in net.connect
Vsevolod Strukchinsky [Tue, 20 Aug 2013 12:31:40 +0000 (18:31 +0600)]
net: family option in net.connect

`dns.lookup` defaults to selecting IPv4 record even if IPv6 is available
for the desired zone. Generally, this approach works, but if IPv4
address is unavailable - there'll be no other way to opt-out and connect using
IPv6 address than calling `dns.lookup` and passing it to `.connect()`
directly.

This commit adds `family` option to `net.connect` method to figure out
this issue.

10 years agofs: use correct self reference for autoClose test
Gil Pedersen [Tue, 20 Aug 2013 13:53:54 +0000 (15:53 +0200)]
fs: use correct self reference for autoClose test

10 years agodoc: Minor typos in dgram doc
isaacs [Tue, 20 Aug 2013 00:55:58 +0000 (17:55 -0700)]
doc: Minor typos in dgram doc

a/an usage.  Thanks @KenanSulayman

10 years agotest: Remove unnecessary assertion
isaacs [Tue, 20 Aug 2013 00:43:38 +0000 (17:43 -0700)]
test: Remove unnecessary assertion

It only fails once in about 1000 times, but that's too many.
It's timing dependent, and the main behavior is covered by the other
assertions in the test anyway.

10 years agoevents: have events module exports EventEmitter
Raynos [Mon, 13 May 2013 19:04:06 +0000 (13:04 -0600)]
events: have events module exports EventEmitter

This change is 100% backwards compatible.

This change will make using `EventEmitter` slightly simpler / nicer and
adheres to the best practice set forth by substack.

```js
var EventEmitter = require("events")

var emitter = new EventEmitter()
```

The only difference is that we now have to set `EventEmitter` as a
property of `EventEmitter` for backwards compatibility like we do with
[`Stream`][1]

We have also set the `usingDomains` property on the `EventEmitter`
constructor itself because that aligns with it's current usage of
`require("events").usingDomains = true`

There are other internals that would benefit from this change as well
like `StringDecoder`