summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* assert: remove unneeded arguments special handlingRich Trott2016-07-051-6/+0
| | | | | | | | | | | | | | | | | | | | Remove special handling when asserting on a pair of arguments objects. The code being removed will only run if both `expected` and `actual` are arguments objects. Given that situation, the subsequent code for handling everything else works just fine. Tests added to confirm expected behavior. This came about while trying to improve test coverage. The segment of code removed had no test coverage. I was unable to write a test that would both exercise the code and fail if the code was removed. Further examination indicated that this was because the special handling was not needed. PR-URL: https://github.com/nodejs/node/pull/7413 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* repl: Enable tab completion for global propertiesLance Ball2016-07-051-10/+24
| | | | | | | | | | | | | | | | | | | | | | | When `useGlobal` is false, tab completion in the repl does not enumerate global properties. Instead of just setting these properties blindly on the global context, e.g. context[prop] = global[prop] Use `Object.defineProperty` and the property descriptor found on `global` for the new property in `context`. Also addresses a previously unnoticed issue where `console` is writable when `useGlobal` is false. If the binary has been built with `./configure --without-intl` then the `Intl` builtin type will not be available in a repl runtime. Check for this in the test. Fixes: https://github.com/nodejs/node/issues/7353 PR-URL: https://github.com/nodejs/node/pull/7369 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* http: replace finish() callback with arrow functionGuy Fraser2016-07-051-8/+7
| | | | | | | | | | | | | | | | | Take advantage of arrow function lexical `this` to avoid defining a `self = this` var which was only used once. Code relating to the `finish` event was split in to two areas of the parent function. Gathered it together to clarify association within the script. Fixes: https://github.com/nodejs/node/issues/7295 PR-URL: https://github.com/nodejs/node/pull/7378 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* repl: fix tab completion for defined commandsPrince J Wesley2016-07-051-2/+2
| | | | | | PR-URL: https://github.com/nodejs/node/pull/7364 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* readline: allow passing prompt to constructorEvan Lucas2016-07-052-6/+7
| | | | | | | | | | | | | | Previously, one would have to call setPrompt after calling rl.createInterface. Now, the prompt string can be set by passing the prompt property. PR-URL: https://github.com/nodejs/node/pull/7125 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Conflicts: test/parallel/test-readline-interface.js
* string_decoder: fix bad utf8 character handlingBrian White2016-07-051-14/+61
| | | | | | | | | | | | | This commit fixes an issue when extra utf8 continuation bytes appear at the end of a chunk of data, causing miscalculations to be made when checking how many bytes are needed to decode a complete character. Fixes: https://github.com/nodejs/node/issues/7308 PR-URL: https://github.com/nodejs/node/pull/7310 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
* tls: avoid calling Buffer.byteLength multiple timesJames M Snell2016-07-051-9/+11
| | | | | | | | | | | | | | | | There's no reason to be calling Buffer.byteLength() twice. Small perf improvement Run 1: tls/convertprotocols.js n=1 v6.2.1 = 11852, new = 12204 ...... -2.89% tls/convertprotocols.js n=50000 v6.2.1 = 515660, new = 570610 ..... -9.63% Run 2: tls/convertprotocols.js n=1 v6.2.1 = 11729, new = 12045 ...... -2.62% tls/convertprotocols.js n=50000 v6.2.1 = 512080, new = 637730 ..... -19.70% PR-URL: https://github.com/nodejs/node/pull/7236 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
* crypto,tls: perf improvements for crypto and tls getCiphersJames M Snell2016-07-053-38/+45
| | | | | | | | | | | | | | | | | | | | | Improve performance of crypto.getCiphers, getHashes, getCurves and tls.getCiphers by consolidating filterDuplicates logic, adding caching of output, and streamlining filterDuplicates implementation. Benchmarks: crypto.getCiphers n=1 v6.2.1 = 2559.3, new = 15890 ...... -83.89% crypto.getCiphers n=5000 v6.2.1 = 3516.3, new = 24203000 ... -99.99% tls.getCiphers n=1 v6.2.1 = 3405.3, new = 14877 ...... -77.11% tls.getCiphers n=5000 v6.2.1 = 6074.4, new = 24202000 ... -99.97% PR-URL: https://github.com/nodejs/node/pull/7225 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Conflicts: lib/internal/util.js
* repl: break on sigint/ctrl+cAnna Henningsen2016-07-052-6/+48
| | | | | | | | | | Adds the ability to stop execution of the current REPL command when receiving SIGINT. This applies only to the default eval function. Fixes: https://github.com/nodejs/node/issues/6612 PR-URL: https://github.com/nodejs/node/pull/6635 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* readline: return old status from _setRawModeAnna Henningsen2016-07-051-1/+5
| | | | | | | | Return the previous raw mode setting from the internal `_setRawMode` so that is easier to reset it to its original state later. PR-URL: https://github.com/nodejs/node/pull/6635 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* vm: add ability to break on sigint/ctrl+cAnna Henningsen2016-07-051-0/+47
| | | | | | | | | | | | | | | | | | | - Adds the `breakEvalOnSigint` option to `vm.runIn(This)Context`. This uses a watchdog thread to wait for SIGINT and generally works just like the existing `timeout` option. - Adds a method to the existing timer-based watchdog to check if it stopped regularly or by running into the timeout. This is used to tell a SIGINT abort from a timer-based one. - Adds (internal) `process._{start,stop}SigintWatchdog` methods to start/stop the watchdog thread used by the above option manually. This will be used in the REPL to set up SIGINT handling before entering terminal raw mode, so that there is no time window in which Ctrl+C fully aborts the process. PR-URL: https://github.com/nodejs/node/pull/6635 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* punycode: update to v2.0.0Mathias Bynens2016-07-051-475/+385
| | | | | | | | | Punycode v2.0.0 drops support for old and non-Node environments. PR-URL: https://github.com/nodejs/node/pull/7267 Fixes: https://github.com/nodejs/node/issues/7224 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Roman Reiss <me@silverwind.io>
* stream: improve Readable.read() performanceBrian White2016-07-052-133/+244
| | | | | | | | | | | | read() performance is improved most by switching from an array to a linked list for storing buffered data. However, other changes that also contribute include: making some hot functions inlinable, faster read() argument checking, and misc code rearrangement to avoid unnecessary code execution. PR-URL: https://github.com/nodejs/node/pull/7077 Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* cluster: work with v8_inspectorcjihrig2016-07-051-1/+3
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/6792 Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: addaleax - Anna Henningsen <anna@addaleax.net> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
* src,lib: v8-inspector supportPavel Feldman2016-07-051-0/+4
| | | | | | | | | | | | | | | | | | This change introduces experimental v8-inspector support. This brings the DevTools debug protocol allowing Node.js to be debugged with Chrome DevTools native, or through other debuggers supporting that protocol. Partial WebSocket support, to the extent required by DevTools, is included. This is derived from the implementation in Blink. v8-inspector support can be disabled by the --without-inspector configure flag. PR-URL: https://github.com/nodejs/node/pull/6792 Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: addaleax - Anna Henningsen <anna@addaleax.net> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl>
* src: refactor require('constants')James M Snell2016-07-0510-15/+41
| | | | | | | | | | | | | | | The require('constants') module is currently undocumented and mashes together unrelated constants. This refactors the require('constants') in favor of distinct os.constants, fs.constants, and crypto.constants that are specific to the modules for which they are relevant. The next step is to document those within the specific modules. PR-URL: https://github.com/nodejs/node/pull/6534 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com> Conflicts: doc/api/fs.md
* buffer: improve creation performance.Ingvar Stepanyan2016-06-251-29/+58
| | | | | | | | | | | | | | | | | | | | | | Improves performance of allocating unsafe buffers, creating buffers from an existing ArrayBuffer and creating .slice(...) from existing Buffer by avoiding deoptimizing change of prototype after Uint8Array allocation in favor of ES6 native subclassing. This is done through an internal ES6 class that extends Uint8Array and is used for allocations, but the regular Buffer function is exposed, so calling Buffer(...) with or without `new` continues to work as usual and prototype chains are also preserved. Performance wins for .slice are +120% (2.2x), and, consequently, for unsafe allocations up to +95% (1.9x) for small buffers, and for safe allocations (zero-filled) up to +30% (1.3x). PR-URL: https://github.com/nodejs/node/pull/7349 Ref: https://github.com/nodejs/node/pull/6893 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com>
* stream: ensure awaitDrain is increased onceDavid Halls2016-06-151-1/+8
| | | | | | | | | | | | | | | Guard against the call to write() inside pipe's ondata pushing more data back onto the Readable, thus causing ondata to be called again. This is fine but results in awaitDrain being increased more than once. The problem with that is when the destination does drain, only a single 'drain' event is emitted, so awaitDrain in this case will never reach zero and we end up with a permanently paused stream. Fixes: https://github.com/nodejs/node/issues/7278 PR-URL: https://github.com/nodejs/node/pull/7292 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* http: fix no dumping after `maybeReadMore`Fedor Indutny2016-06-151-0/+9
| | | | | | | | | | | | When `maybeReadMore` kicks in on a first bytes of incoming data, the `req.read(0)` will be invoked and the `req._consuming` will be set to `true`. This seemingly harmless property leads to a dire consequences: the server won't call `req._dump()` and the whole HTTP/1.1 pipeline will hang (single connection). PR-URL: https://github.com/nodejs/node/pull/7211 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
* http: optimize checkInvalidHeaderChar()Brian White2016-06-151-5/+24
| | | | | | | | | | | | | | | | This commit optimizes checkInvalidHeaderChar() by unrolling the character checking loop a bit. Additionally, some changes to the benchmark runner are needed in order for the included benchmark to be run correctly. Specifically, the regexp used to parse `key=value` parameters contained a greedy quantifier that was causing the `key` to match part of the `value` if `value` contained an equals sign. PR-URL: https://github.com/nodejs/node/pull/6570 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
* http: optimize checkIsHttpToken()Brian White2016-06-151-36/+49
| | | | | | | | | | | This commit both makes checkIsHttpToken() inlinable and extracts the character checking logic to a separate inlinable function so that the main loop can be unrolled a bit. PR-URL: https://github.com/nodejs/node/pull/6570 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
* stream: reset awaitDrain after manual .resume()Anna Henningsen2016-06-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Reset the `readableState.awaitDrain` counter after manual calls to `.resume()`. What might happen otherwise is that a slow consumer at the end of the pipe could end up stalling the piping in the following scenario: 1. The writable stream indicates that its buffer is full. 2. This leads the readable stream to `pause()` and increase its `awaitDrain` counter, which will be decreased by the writable’s next `drain` event. 3. Something calls `.resume()` manually. 4. The readable continues to pipe to the writable, but once again the writable stream indicates that the buffer is full. 5. The `awaitDrain` counter is thus increased again, but since it has now been increased twice for a single piping destination, the next `drain` event will not be able to reset `awaitDrain` to zero. 6. The pipe is stalled and no data is passed along anymore. The solution in this commit is to reset the `awaitDrain` counter to zero when `resume()` is called. Fixes: https://github.com/nodejs/node/issues/7159 PR-URL: https://github.com/nodejs/node/pull/7160 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* cluster: don't send messages if no IPC channelSantiago Gimeno2016-06-151-0/+3
| | | | | | | | | | Avoid sending messages if the IPC channel is already disconnected. It avoids undesired errors when calling `process.disconnect` when there are still pending IPC messages. PR-URL: https://github.com/nodejs/node/pull/7132 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* debugger: remove obsolete setTimeoutRich Trott2016-06-151-7/+1
| | | | | | | | | | | Remove obsolete `setTimeout()` introduced in 3148f1400. The fix for the problem is in b266074347. (For the record, I mostly don't know what I'm talking about here but am summarizing from an IRC #node-dev conversation with @indutny on 04-Jun-2016.) PR-URL: https://github.com/nodejs/node/pull/7154 Reviewed-By: Fedor Indutny <fedor@indutny.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* http: wait for both prefinish/end to keepaliveFedor Indutny2016-06-151-3/+24
| | | | | | | | | | | When `free`ing the socket to be reused in keep-alive Agent wait for both `prefinish` and `end` events. Otherwise the next request may be written before the previous one has finished sending the body, leading to a parser errors. PR-URL: https://github.com/nodejs/node/pull/7149 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* repl: refine handling of illegal tokensRich Trott2016-06-151-3/+15
| | | | | | | | | | | Illegal tokens are only recoverable in string literals, RegExp literals, and block comments. If not in one of these constructs, immediately return an error rather than giving the user false hope by giving them a chance to try to recover. PR-URL: https://github.com/nodejs/node/pull/7104 Fixes: https://github.com/nodejs/node/issues/3611 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* fs: execute mkdtemp's callback with no contextSakthipriyan Vairamani2016-06-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | All the callback functions in `fs` module are supposed to be executed with no context (`this` value should not be a valid object). But `mkdtemp`'s callback will have the `FSReqWrap` object as the context. Sample code to reproduce the problem 'use strict'; const fs = require('fs'); fs.mkdtemp('/tmp/abcd', null, function() { console.log(this); }); This would print FSReqWrap { oncomplete: [Function] } But that should have printed `null` and this patch fixes that. PR-URL: https://github.com/nodejs/node/pull/7068 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* debugger: fix --debug-brk interaction with -eRich Trott2016-06-151-26/+33
| | | | | | | | | | | The command line flag `--debug-brk` was ignored when the `-e` flag was also present. This change allows the flags to both be honored when they are used in a single command line. PR-URL: https://github.com/nodejs/node/pull/7089 Fixes: https://github.com/nodejs/node/issues/3589 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* tty: use blocking mode on OS XJeremiah Senkpiel2016-06-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OS X has a tiny 1kb hard-coded buffer size for stdout / stderr to TTYs (terminals). Output larger than that causes chunking, which ends up having some (very small but existent) delay past the first chunk. That causes two problems: 1. When output is written to stdout and stderr at similar times, the two can become mixed together (interleaved). This is especially problematic when using control characters, such as \r. With interleaving, chunked output will often have lines or characters erased unintentionally, or in the wrong spots, leading to broken output. CLI apps often extensively use such characters for things such as progress bars. 2. Output can be lost if the process is exited before chunked writes are finished flushing. This usually happens in applications that use `process.exit()`, which isn't infrequent. See https://github.com/nodejs/node/issues/6980 for more info. This became an issue as result of the Libuv 1.9.0 upgrade. A fix to an unrelated issue broke a hack previously required for the OS X implementation. This resulted in an unexpected behavior change in node. The 1.9.0 upgrade was done in c3cec1eefc9f3b55a3fb7bd623b3d921f493870d, which was included in v6.0.0. Full details of the Libuv issue that induced this are at https://github.com/nodejs/node/issues/6456#issuecomment-219974514 Refs: https://github.com/nodejs/node/pull/1771 Refs: https://github.com/nodejs/node/issues/6456 Refs: https://github.com/nodejs/node/pull/6773 Refs: https://github.com/nodejs/node/pull/6816 PR-URL: https://github.com/nodejs/node/pull/6895 Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* buffer: ignore negative allocation lengthsAnna Henningsen2016-06-021-2/+2
| | | | | | | | | | | | | | Treat negative length arguments to `Buffer()`/`allocUnsafe()` as if they were zero so the allocation does not affect the pool’s offset. Fixes: https://github.com/nodejs/node/issues/7047 PR-URL: https://github.com/nodejs/node/pull/7051 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
* cluster: expose result of send()cjihrig2016-06-021-4/+4
| | | | | | | | | | | | | | | There are several places in the cluster module where a version of process.send() is called, but the result is swallowed. Most of these cases are internal, but Worker.prototype.send(), which is publicly documented, also suffers from this problem. This commit exposes the return value to facilitate better error handling, and bring Worker.prototype.send() into compliance with the documentation. PR-URL: https://github.com/nodejs/node/pull/6998 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* cluster: rewrite debug ports consistentlycjihrig2016-06-021-2/+6
| | | | | | | | | | | | When debug flags are passed to clustered applications, the debug port is rewritten for each worker process to avoid collisions. Prior to this commit, each debug flag would get a unique value. This commit reworks the logic to assign the same port value to all debug flags for a single worker. PR-URL: https://github.com/nodejs/node/pull/7050 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
* string_decoder: rewrite implementationBrian White2016-06-021-183/+193
| | | | | | | | | | | | | | This commit provides a rewrite of StringDecoder that both improves performance (for non-single-byte encodings) and understandability. Additionally, StringDecoder instantiation performance has increased considerably due to inlinability and more efficient encoding name checking. PR-URL: https://github.com/nodejs/node/pull/6777 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* tls,https: respect address family when connectingBen Noordhuis2016-06-022-0/+6
| | | | | | | | | | Respect the `{ family: 6 }` address family property when connecting to a remote peer over TLS. Fixes: https://github.com/nodejs/node/issues/4139 Fixes: https://github.com/nodejs/node/issues/6440 PR-URL: https://github.com/nodejs/node/pull/6654 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* zlib: release callback and buffer after processingMatt Lavin2016-06-021-0/+10
| | | | | | PR-URL: https://github.com/nodejs/node/pull/6955 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuval Brik <yuval@brik.org.il>
* cluster: reset handle index on closeSantiago Gimeno2016-06-021-12/+14
| | | | | | | | | | | It allows reopening a server after it has been closed. Fixes: https://github.com/nodejs/node/issues/6693 PR-URL: https://github.com/nodejs/node/pull/6981 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
* dgram: copy the list in sendMatteo Collina2016-06-021-16/+24
| | | | | | | | | | | | | | | | | This commit fix a possible crash situation in dgram send(). A crash is possible if an array is passed, and then altered after the send call, as the call to libuv is wrapped in process.nextTick(). It also avoid sending an empty array to libuv by allocating an empty buffer. It also does some cleanup inside send() to increase readability. It removes test flakyness by use common.mustCall and common.platformTimeout. Fixes situations were some events were not asserted to be emitted. Fixes: https://github.com/nodejs/node/issues/6616 PR-URL: https://github.com/nodejs/node/pull/6804 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* debugger: propagate --debug-port= to debuggeeBen Noordhuis2016-06-021-2/+2
| | | | | | | | | | | | | | | | Before this commit `node --debug-port=1234 debug t.js` ignored the --debug-port= argument, binding to the default port 5858 instead, making it impossible to debug more than one process on the same machine that way. This commit also reduces the number of places where the default port is hard-coded by one. Fixes: https://github.com/nodejs/node/issues/3345 PR-URL: https://github.com/nodejs/node/pull/3470 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* tls: catch `certCbDone` exceptionsFedor Indutny2016-06-021-1/+5
| | | | | | | | | Catch and emit `certCbDone` exceptions instead of throwing them as `uncaughtException` and crashing the whole process. Fix: https://github.com/nodejs/node/issues/6822 PR-URL: https://github.com/nodejs/node/pull/6887 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* child_process: measure buffer length in bytesRich Trott2016-06-021-30/+41
| | | | | | | | | | This change fixes a known issue where `maxBuffer` limits by characters rather than bytes. Benchmark added to confirm no performance regression occurs with this change. PR-URL: https://github.com/nodejs/node/pull/6764 Fixes: https://github.com/nodejs/node/issues/1901 Reviewed-By: Brian White <mscdex@mscdex.net>
* cluster: guard against undefined message handlerscjihrig2016-06-021-1/+1
| | | | | | | | | | | | | | cluster's internal message handling includes a cache of callback functions. Once the message for that callback is received, it is removed from the cache. If, for any reason, the same message ID is processed twice, the callback will be missing from the cache and cluster will try to call undefined as a function. This commit guards against this scenario. Refs: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6902 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
* cluster: close ownerless handles on disconnect()cjihrig2016-06-021-1/+5
| | | | | | | | | | | | | When a worker is disconnecting, it shuts down all of the handles it is waiting on. It is possible that a handle does not have an owner, which causes a crash. This commit closes such handles without accessing the missing owner. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
* child_process: emit IPC messages on next tickcjihrig2016-06-021-1/+3
| | | | | | | | | | | | | | Currently, if an IPC event handler throws an error, it can cause the message to not be consumed, leading to messages piling up. This commit causes IPC events to be emitted on the next tick, allowing the channel's processing logic to move forward as normal. Fixes: https://github.com/nodejs/node/issues/6561 PR-URL: https://github.com/nodejs/node/pull/6909 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
* module: don't cache uninitialized builtinsAnna Henningsen2016-06-021-8/+15
| | | | | | | | | | | | | | | | Don't cache the exported values of fully uninitialized builtins. This works by adding an additional `loading` flag that is only active during initial loading of an internal module and checking that either the module is fully loaded or is in that state before using its cached value. This has the effect that builtins modules which could not be loaded (e.g. because compilation failed due to missing stack space) can be loaded at a later point. Fixes: https://github.com/nodejs/node/issues/6899 PR-URL: https://github.com/nodejs/node/pull/6907 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* child_process: allow buffer encoding in spawnSynccjihrig2016-06-021-1/+1
| | | | | | | | | | | | When the 'buffer' encoding is passed to spawnSync(), an exception is thrown in Buffer's toString() method because 'buffer' is not a valid encoding there. This commit special cases the 'buffer' encoding. Fixes: https://github.com/nodejs/node/issues/6930 PR-URL: https://github.com/nodejs/node/pull/6939 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* buffer: fix single digit hex string handlingJustin Sprigg2016-06-021-3/+3
| | | | | | | | Fixes single digit hex strings not raising TypeError on Buffer creation. Fixes: https://github.com/nodejs/node/issues/6770 PR-URL: https://github.com/nodejs/node/pull/6775 Reviewed-By: Anna Henningsen <anna@addaleax.net>
* util: pretty-print SIMD typesBen Noordhuis2016-06-021-0/+54
| | | | | | | | | | | | | | | | | | | | Before: Bool32x4 {} Float32x4 {} Int32x4 {} // etc. After: Bool32x4 [ false, false, false, false ] Float32x4 [ NaN, NaN, NaN, NaN ] Int32x4 [ 0, 0, 0, 0 ] // etc. PR-URL: https://github.com/nodejs/node/pull/6917 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Robert Jefe Lindstaedt <robert.lindstaedt@gmail.com>
* fs: move mkdtemp* functions near static functionsSakthipriyan Vairamani2016-06-021-39/+41
| | | | | | PR-URL: https://github.com/nodejs/node/pull/6828 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
* fs: mkdtemp shouldn't crash if no callback passedSakthipriyan Vairamani2016-06-021-1/+2
| | | | | | | | | | As it is, `fs.mkdtemp` crashes with a C++ assertion if the callback function is not passed. This patch uses `maybeCallback` to create one, if no callback function is passed. PR-URL: https://github.com/nodejs/node/pull/6828 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
* http: use `localAddress` instead of `path`Dirceu Pereira Tiegs2016-06-021-2/+2
| | | | | | | | | | Fix `options` usage on `lib/_http_agent.js` for the Legacy API. Fixes: https://github.com/nodejs/node/issues/5051 PR-URL: https://github.com/nodejs/node/pull/5190 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>