0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

4186 Commits

Author SHA1 Message Date
Brian White
14c76f8671
http: misc cleanup and minor optimizations
PR-URL: https://github.com/nodejs/node/pull/6533
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2016-12-29 14:18:53 -05:00
Brian White
175ed520c1
http: reuse existing headers array for raw values
PR-URL: https://github.com/nodejs/node/pull/6533
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2016-12-29 14:18:49 -05:00
Brian White
4c9dd6822e
events: improve once() performance
This commit takes advantage of the performance improvements V8 has
made to function.bind() in V8 5.4 and uses it to avoid constant
recompilation/reoptimization of the wrapper closure used in once().
This change results in ~27% performance increase for once().

PR-URL: https://github.com/nodejs/node/pull/10445
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-28 21:23:25 -05:00
Brian White
13a4887ee9 buffer: improve allocation performance
assertSize() is adjusted to be inlineable according to V8's default
function size limits when determining inlineability. This results in
up to 11% performance gains when allocating any kind of Buffer.

Avoid avoids use of in, resulting in ~50% improvement when creating
a Buffer from an array-like object.

PR-URL: https://github.com/nodejs/node/pull/10443
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-12-27 14:57:06 -08:00
Anna Henningsen
f2ef850f11
fs: support Uint8Array input to methods
Allow `fs.read`, `fs.write` and `fs.writeFile` to take
`Uint8Array` arguments.

PR-URL: https://github.com/nodejs/node/pull/10382
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
2016-12-26 10:08:42 +01:00
cjihrig
fc7b0dda85 child_process: improve input validation
This commit applies stricter input validation in
normalizeSpawnArguments(), which is run by all of the
child_process methods. Additional checks are added for spawnSync()
specific inputs.

Fixes: https://github.com/nodejs/node/issues/8096
Fixes: https://github.com/nodejs/node/issues/8539
Refs: https://github.com/nodejs/node/issues/9722
PR-URL: https://github.com/nodejs/node/pull/8312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-12-25 12:48:46 -05:00
Junshu Okamoto
c65d55f087 url: do not truncate long hostnames
Currently, around line 417 lib/url.js is truncating hostname and put the
rest of hostname to the path if hostname length after `.`  is equal or
more than 63. This behavior is different from browser behavior. I
changed the code so that it doesn’t truncate.

I also added the test example which has more than 63 length in after
`.` in hostname in test url.

PR-URL: https://github.com/nodejs/node/pull/9292
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-12-24 21:06:23 -08:00
Jeremy Yallop
5dc44874c3 fs: cache non-symlinks in realpathSync.
Extend `fs.realpathSync` to cache the results for paths that are not
symlinks in addition to caching symlink mappings.

PR-URL: https://github.com/nodejs/node/pull/10253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 23:40:45 -08:00
Evan Lucas
e248f7f9e7 repl: allow autocompletion for scoped packages
Previously, autocompletion of scoped packages was not supported by the
repl due to not including the `@` character in the regular expression.

PR-URL: https://github.com/nodejs/node/pull/10296
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-22 22:03:39 -08:00
Michaël Zasso
966e5cfb81 tools: enforce linebreak after ternary operators
This is to be consistent with the other operators and helps
understanding the context when the code is grepped.

PR-URL: https://github.com/nodejs/node/pull/10213
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-22 20:27:59 -08:00
Anna Henningsen
beca3244e2
buffer: allow Uint8Array input to methods
Allow all methods on `buffer` and `Buffer` to take `Uint8Array`
arguments where it makes sense. On the native side, there is
effectively no difference, and as a bonus the `isUint8Array`
check is faster than `instanceof Buffer`.

PR-URL: https://github.com/nodejs/node/pull/10236
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2016-12-21 07:48:14 +01:00
Francis Gulotta
1081f0f33d fs: remove needless assignment of null
This line `pool = null;` isn't needed and has
been around since the first iteration of streams.
I can't find a good reason for it to exist, it's
not more readable, nor does it seem to trick the
compiler into any optimizations.

PR-URL: https://github.com/nodejs/node/pull/10260
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
2016-12-19 20:05:22 -05:00
Sam Roberts
0b44384561 tls: allow obvious key/passphrase combinations
Passphrase is now used whether keys are provided singly, in an array of
string/buffer, or an array of object, where it used to be ignored in
some argument combinations. Specifically, these now work as expected:

  key: [encryptedPem],
  passphrase: 'passphrase'

and

  key: [{pem: encryptedPem}]
  passphrase: 'passphrase'

and

  key: [{pem: unencryptedPem}]

PR-URL: https://github.com/nodejs/node/pull/10294
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-12-19 13:42:56 -08:00
Sean Villars
5d14602181 cluster: return worker reference from disconnect()
Changes disconnect() to return a refererence to the worker.
This will enable method chaining such as

    worker.disconnect().once('disconnect', doThis);

PR-URL: https://github.com/nodejs/node/pull/10019
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2016-12-19 09:46:31 -08:00
hveldstra
9f6f0f748c timers: fix handling of cleared immediates
If current immediate has no callback, move on to the next one in
the queue.

Fixes: https://github.com/nodejs/node/issues/9756
PR-URL: https://github.com/nodejs/node/pull/9759
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2016-12-14 10:10:22 -05:00
Ethan Arrowood
e432c2bfaa fs: remove unused argument from copyObject()
The fs function copyObject() had two arguments:
source and target. On the first line of the function it
assigned the target variable to:
arguments.length >= 2 ? target : {};

The function copyObject() was not called directly by
any test, but it is called in other fs functions. When it
was called it was only ever called with a single argument,
source. Thus I have removed the target argument and assigned
it to an empty object like it was being assigned to in the
original ternary operator.

PR-URL: https://github.com/nodejs/node/pull/10041
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-12-14 15:17:03 +01:00
Brian White
f3cf8e9808
fs: do not pass Buffer when toString() fails
Even though an Error object is passed to the callback when readFile()
fails due to toString() failing, it is a bit strange to still see
data passed as the second argument. This commit changes that and only
passes the Error object in that case.

PR-URL: https://github.com/nodejs/node/pull/9670
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-14 03:29:33 -05:00
Jay Brownlee
4f97a146ff
url, test: fix typo in inspect output, add test
In the string returned from URL.inspect there was an extra semicolon
at the end when showHidden === true. The semicolon has been
removed and a test for the inspect function has been added. The test
parses the returned string, validates all of the contained keys/values
and tests logic related to the showHidden option.

PR-URL: https://github.com/nodejs/node/pull/10231
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2016-12-14 05:20:42 +01:00
Joyee Cheung
3d353c749c
buffer: consistent error for length > kMaxLength
- Always return the same error message(hopefully more informative)
  for buffer length > kMaxLength and avoid getting into V8 C++ land
  for unnecessary checks.
- Use accurate RegExp(reusable as `common.bufferMaxSizeMsg`)
  in tests for this error.
- Separate related tests from test-buffer-alloc.

PR-URL: https://github.com/nodejs/node/pull/10152
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-13 19:25:13 +01:00
Sam Roberts
a28e949145 tls: do not refer to secureOptions as flags
Its confusing to have multiple names for the same thing, use
secureOptions consistently.

PR-URL: https://github.com/nodejs/node/pull/9800
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2016-12-12 08:15:54 -08:00
Sam Roberts
d4050b38d6 tls: document and test option-less createServer
Either the options or the listener argument to tls.createServer() was
optional, but not both. This makes no sense, so align the argument
checking and documentation with net.createServer(), which accepts the
same option sequence, and which tls.createServer() is modelled on.

PR-URL: https://github.com/nodejs/node/pull/9800
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2016-12-12 08:15:36 -08:00
Sam Roberts
c3839f7ed4 tls: fix/annotate connect arg comments
PR-URL: https://github.com/nodejs/node/pull/9800
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2016-12-12 08:13:55 -08:00
Anna Henningsen
d4f00fe109
buffer: fix single-character string filling
Fix the fast path for `buffer.fill()` with a single-character string.

The fast path only works for strings that are equivalent to a
single-byte buffer, but that condition was not checked properly
for the `utf8` or `utf16le` encodings and is always true for the
`latin1` encoding.

This change fixes these problems.

Fixes: https://github.com/nodejs/node/issues/9836
PR-URL: https://github.com/nodejs/node/pull/9837
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-12-12 16:58:40 +01:00
joyeecheung
a84017a689 url, test: including base argument in originFor
- Add tests to check if the `originFor` implementation
  for WHATWG url parsing is correnct.
- Fix `originFor` by including a base as argument

PR-URL: https://github.com/nodejs/node/pull/10021
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-12 09:54:44 -05:00
Ben Noordhuis
aa77b767b6 lib,src: support values > 4GB in heap statistics
We were transporting the heap statistics as uint32 values to JS land but
those wrap around for values > 4 GB.  Use 64 bits floats instead, those
should last us a while.

Fixes: https://github.com/nodejs/node/issues/10185
PR-URL: https://github.com/nodejs/node/pull/10186
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
2016-12-11 14:45:52 +01:00
Michaël Zasso
4d11c2ce5c lib,test: use consistent operator linebreak style
We have a tacit rule that for multiline statements, the operator should
be placed before the linebreak. This commit commit fixes the few
violations of this rule in the code base.
This allows us to enable the corresponding ESLint rule.

PR-URL: https://github.com/nodejs/node/pull/10178
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-12-10 10:46:42 +01:00
Karl Böhlmark
9a5d47542d http: remove stale timeout listeners
In order to prevent a memory leak when using keep alive, ensure that the
timeout listener for the request is removed when the response has ended.

PR-URL: https://github.com/nodejs/node/pull/9440
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-08 16:05:22 -05:00
Luca Maraschi
df3978421b http: verify client method is a string
Prior to this commit, it was possible to pass a truthy non-string
value as the HTTP method to the HTTP client, resulting in an
exception being thrown. This commit adds validation to the method.

PR-URL: https://github.com/nodejs/node/pull/10111
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-08 09:51:07 -05:00
Timothy Gu
61d6293033 url: improve URLSearchParams spec compliance
- Make URLSearchParams constructor spec-compliant
- Strip leading `?` in URL#search's setter
- Spec-compliant iterable interface
- More precise handling of update steps as mandated by the spec
- Add class strings to URLSearchParams objects and their prototype
- Make sure `this instanceof URLSearchParams` in methods

Also included are relevant tests from W3C's Web Platform Tests
(https://github.com/w3c/web-platform-tests/tree/master/url).

Fixes: https://github.com/nodejs/node/issues/9302
PR-URL: https://github.com/nodejs/node/pull/9484
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-07 12:19:23 -05:00
Axel Monroy
1be73e828d url: add a got host pattern in url.js
Add a hostPattern variable for readable purposes

PR-URL: https://github.com/nodejs/node/pull/9653
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-12-06 12:37:24 -08:00
Teddy Katz
9d493d0064
repl: avoid parsing division operator as regex
This improves the heuristic used in multiline-prompt mode to determine
whether a given slash character is at the beginning of a regular
expression.

PR-URL: https://github.com/nodejs/node/pull/10103
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@keybase.io>
Fixes: https://github.com/nodejs/node/issues/9300
2016-12-06 02:26:24 -05:00
Jackson Tian
fc31055117 internal/util: move the case 'latin1'
make the `case 'latin1':` near by `case 'binary':`.

PR-URL: https://github.com/nodejs/node/pull/9646
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2016-12-05 14:43:09 -08:00
Lance Ball
6410534ec1 debugger: call this.resume() after this.run()
When the debugger has started we need to call `this.resume` otherwise,
the prompt won't appear.

Fixes: https://github.com/nodejs/node/issues/9854
PR-URL: https://github.com/nodejs/node/pull/10099
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2016-12-05 14:25:39 -05:00
Anna Henningsen
196d27dd8c
promise: better stack traces for --trace-warnings
Give better stack traces for `PromiseRejectionHandledWarning`
and `UnhandledPromiseRejectionWarning`s.

For `PromiseRejectionHandledWarning`, when it is likely that there
is an `Error` object generated, it is created early to provide a
proper stack trace.

For `UnhandledPromiseRejectionWarning`, the stack trace of the
underlying error object is used, if possible.

Fixes: https://github.com/nodejs/node/issues/9523
PR-URL: https://github.com/nodejs/node/pull/9525
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2016-12-05 18:19:34 +01:00
brad-decker
bbed075325 child_process: name anonymous functions
Refs: https://github.com/nodejs/node/issues/8913
PR-URL: https://github.com/nodejs/node/pull/9880
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-12-05 07:35:52 -08:00
Prince J Wesley
9366b8d90a
repl: preprocess only for defaultEval
Code preprocessing is applicable only for default
eval function. Therefore, Moved `preprocess` function
invocation inside `defaultEval` function.

Fixes: https://github.com/nodejs/node/issues/9743
PR-URL: https://github.com/nodejs/node/pull/9752
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-12-05 19:30:56 +05:30
Sakthipriyan Vairamani (thefourtheye)
720d01f006
buffer: convert offset & length to int properly
As per ecma-262 2015's #sec-%typedarray%-buffer-byteoffset-length,
`offset` would be an integer, not a 32 bit unsigned integer. Also,
`length` would be an integer with the maximum value of 2^53 - 1, not a
32 bit unsigned integer.

This would be a problem because, if we create a buffer from an
arraybuffer, from an offset which is greater than 2^32, it would be
actually pointing to a different location in arraybuffer. For example,
if we use 2^40 as offset, then the actual value used will be 0,
because `byteOffset >>>= 0` will convert `byteOffset` to a 32 bit
unsigned int, which is based on 2^32 modulo.

This is a redo, as the ca37fa527f broke
CI.

Refer: https://github.com/nodejs/node/pull/9814
Refer: https://github.com/nodejs/node/pull/9492

PR-URL: https://github.com/nodejs/node/pull/9815

Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2016-12-05 18:15:49 +05:30
Rich Trott
34a6c858bd debugger: refactor _debugger.js
* `==` -> `===`
* use white space in array to improve readability

PR-URL: https://github.com/nodejs/node/pull/9860
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-12-04 22:58:20 -08:00
Safia Abdalla
883173289d
url: add inspect function to TupleOrigin
This adds a simple inspect function the the TupleOrigin class.
This adds tests for the newly added inspect function in the TupleOrigin
class.

PR-URL: https://github.com/nodejs/node/pull/10039
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2016-12-05 03:12:55 +01:00
joyeecheung
4422c35c5e
test,url: improve escaping in url.parse
- rename variables in autoEscapeStr so they are easier to understand
- comment the escaping algorithm
- increase coverage for autoEscapeStr

PR-URL: https://github.com/nodejs/node/pull/10083
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-12-05 00:44:38 +01:00
Walter Beller-Morales
20fa6e7d07 lib: use === in _http_server and _tls_wrap
Minor fix to favor strict equality in http_server.js and tls_wrap.js
to ensure accurate comparisons without type coercion.

PR-URL: https://github.com/nodejs/node/pull/9849
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-12-02 19:36:38 -06:00
Teddy Katz
24a98dd810
repl: fix generator function preprocessing
Function declarations in the REPL are preprocessed into variable
declarations before being evaluated. However, the preprocessing logic
did not account for the star in a generator function declaration, which
caused the preprocessor to output invalid syntax in some circumstances.

PR-URL: https://github.com/nodejs/node/pull/9852
Fixes: https://github.com/nodejs/node/issues/9850
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2016-12-02 03:15:39 -05:00
Bryan English
edb78aa2a6 constants: errors -> errno
lib/constants.js was incorrectly copying the constants from the
binding, by copying from `contants.os.errors` instead of
`constants.os.errno`.

PR-URL: https://github.com/nodejs/node/pull/9349
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Ron Korving <ron@ronkorving.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-11-29 07:33:24 -05:00
Anna Henningsen
4fffe32a4b Revert "buffer: runtime deprecation of calling Buffer without new"
This reverts commit f2fe5583c4
(https://github.com/nodejs/node/pull/8169) as the original
justification for the runtime-deprecation does not appear
to justify the disruption to Node’s existing ecosystem.
Futhermore, the possibility of deprecating the Buffer constructor
entirely in v8.0 might lead to people having to change their code twice.

PR-URL: https://github.com/nodejs/node/pull/9529
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Nikolai Vavilov <vvnicholas@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2016-11-28 11:10:11 -06:00
Rich Trott
6b2aa1a2b9 Revert "buffer: convert offset & length to int properly"
This reverts commit ca37fa527f.

A test provided by the commit fails on most (but not all) platforms on
CI.

PR-URL: https://github.com/nodejs/node/pull/9814
Ref: https://github.com/nodejs/node/pull/9492
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
2016-11-26 11:40:24 -08:00
Sakthipriyan Vairamani (thefourtheye)
ca37fa527f buffer: convert offset & length to int properly
As per ecma-262 2015's #sec-%typedarray%-buffer-byteoffset-length,
`offset` would be an integer, not a 32 bit unsigned integer. Also,
`length` would be an integer with the maximum value of 2^53 - 1, not a
32 bit unsigned integer.

This would be a problem because, if we create a buffer from an
arraybuffer, from an offset which is greater than 2^32, it would be
actually pointing to a different location in arraybuffer. For example,
if we use 2^40 as offset, then the actual value used will be 0,
because `byteOffset >>>= 0` will convert `byteOffset` to a 32 bit
unsigned int, which is based on 2^32 modulo.

PR-URL: https://github.com/nodejs/node/pull/9492

Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
2016-11-26 11:15:34 +05:30
Pedro Lima
1f45d7aa41 https: name anonymous functions in https
Naming anonymous function in the https module

PR-URL: https://github.com/nodejs/node/pull/9217
Ref: https://github.com/nodejs/node/issues/8913
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2016-11-25 13:55:17 -05:00
Prince J Wesley
0f4c7b8c37 lib,tools: remove unneeded escaping of /
The `/` character does not need to be escaped when occurring inside a
character class in a regular expression. Remove such instances of
escaping in the code base.

PR-URL: https://github.com/nodejs/node/pull/9591
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2016-11-23 22:06:24 -08:00
Jeremiah Senkpiel
3f1e38c847 timers: use consistent checks for canceled timers
Previously not all codepaths set `timer._idleTimeout = -1` for canceled
or closed timers, and not all codepaths checked it either.

Unenroll uses this to say that a timer is indeed closed and it is the
closest thing there is to an authoritative source for this.

Refs: https://github.com/nodejs/node/pull/9606
Fixes: https://github.com/nodejs/node/issues/9561
PR-URL: https://github.com/nodejs/node/pull/9685
Reviewed-By: Rich Trott <rtrott@gmail.com>
2016-11-22 12:28:41 -05:00
Gareth Ellis
440057eae0
src: extend HeapStatistics with new fields
src: Add does_zap_garbage, malloced_memory and
peak_malloced_memory to v8 HeapStatistics

Following https://github.com/nodejs/code-and-learn/issues/56 I
have exposed does_zap_garbage to HeapStatistics.
The other fields, malloced_memory and peak_malloced_memory don't
seem to be in the current version of v8 in master.

PR-URL: https://github.com/nodejs/node/pull/8610
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-11-20 02:23:00 +01:00