0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-29 23:16:30 +01:00
Commit Graph

194 Commits

Author SHA1 Message Date
Robert Nagy
027e1c706d http: ensure client request emits close
If socket creation failed then an error would be
emitted on the client request object, but not
'close' nor would destroyed be set to true.

PR-URL: https://github.com/nodejs/node/pull/33178
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-04 11:35:58 +02:00
Alex R
b149eefa82 http: fix incorrect headersTimeout measurement
For keep-alive connections, the headersTimeout may fire during
subsequent request because the measurement was reset after
a request and not before a request.

PR-URL: https://github.com/nodejs/node/pull/32329
Fixes: https://github.com/nodejs/node/issues/27363
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-04-02 14:50:20 +02:00
Robert Nagy
2bf02285a3
http: move free socket error handling to agent
The http client should not know anything about free sockets. Let
the agent handle its pool of sockets.

PR-URL: https://github.com/nodejs/node/pull/32003
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-03-30 10:25:03 +02:00
James M Snell
ca19d553cf
http: fixup options.method error message
Use `options.method` instead of just `method`

Signed-off-by: James M Snell <jasnell@gmail.com>

PR-URL: https://github.com/nodejs/node/pull/32471
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-03-27 16:01:24 +01:00
Robert Nagy
c1b2f6afbe http: detach socket from IncomingMessage on keep-alive
If the socket is not detached then a future call to res.destroy
(through e.g. pipeline) would unecessarily kill the socket while
its in the agent free list.

PR-URL: https://github.com/nodejs/node/pull/32153
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-03-10 23:44:49 +01:00
Robert Nagy
173d044d09 http: align OutgoingMessage and ClientRequest destroy
Added .destroyed property to OutgoingMessage and ClientRequest
to align with streams.

Fixed ClientRequest.destroy to dump res and re-use socket in agent
pool aligning it with abort.

PR-URL: https://github.com/nodejs/node/pull/32148
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-03-10 18:15:01 +01:00
Anna Henningsen
d6f1e395ca
http: make --insecure-http-parser configurable per-stream or per-server
From the issue:

> Some servers deviate from HTTP spec enougth that Node.js can't
> communicate with them, but "work" when `--insecure-http-parser`
> is enabled globally. It would be useful to be able to use this
> mode, as a client, only when connecting to known bad servers.

This is largely equivalent to https://github.com/nodejs/node/pull/31446
in terms of code changes.

Fixes: https://github.com/nodejs/node/issues/31440
Refs: https://github.com/nodejs/node/pull/31446

PR-URL: https://github.com/nodejs/node/pull/31448
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-01-24 17:54:23 +01:00
Sebastien Ahkrin
c9b93e2344 lib: replace use of Error with primordials
PR-URL: https://github.com/nodejs/node/pull/31163
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2020-01-04 14:50:18 -08:00
Robert Nagy
7c70dbb986
http: free listeners on free sockets
Reduced memory usage by ensuring free sockets don't have extra
listeners while in the pool.

PR-URL: https://github.com/nodejs/node/pull/29259
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-01-03 01:36:15 +01:00
Trivikram Kamat
ddedf8eaac http: use for...of in http library code
PR-URL: https://github.com/nodejs/node/pull/30958
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-12-17 10:18:00 -08:00
Anatoli Papirovski
fea1f1cb9a http: remove unnecessary bind
process.nextTick accepts additional parameters which
are passed through to the callback. Use that instead
of binding the function to a context.

PR-URL: https://github.com/nodejs/node/pull/28131
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-12-14 09:01:42 -05:00
Sam Roberts
02a0c74861 http: llhttp opt-in insecure HTTP header parsing
Allow insecure HTTP header parsing. Make clear it is insecure.

See:
- https://github.com/nodejs/node/pull/30553
- https://github.com/nodejs/node/issues/27711#issuecomment-556265881
- https://github.com/nodejs/node/issues/30515

PR-URL: https://github.com/nodejs/node/pull/30567
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-12-09 09:56:16 -08:00
Anna Henningsen
6bf5a1d691
http: make maximum header size configurable per-stream or per-server
Make `maxHeaderSize` a.k.a. `--max-header-size` configurable now that
the legacy parser is gone (which only supported a single global value).

Refs: https://github.com/nodejs/node/pull/30567

PR-URL: https://github.com/nodejs/node/pull/30570
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
2019-12-01 03:00:46 +01:00
Michaël Zasso
1f9a5ae7aa
lib: use static Number properties from primordials
PR-URL: https://github.com/nodejs/node/pull/30686
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-11-30 13:45:38 +01:00
Michaël Zasso
7fc5980cfe
lib: enforce use of Boolean from primordials
Refs: https://github.com/nodejs/node/issues/30697

PR-URL: https://github.com/nodejs/node/pull/30698
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
2019-11-30 13:37:23 +01:00
Michaël Zasso
141a6e34ee
lib: enforce use of Array from primordials
PR-URL: https://github.com/nodejs/node/pull/30635
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2019-11-27 19:29:01 +01:00
Michaël Zasso
0646eda4fc
lib: flatten access to primordials
Store all primordials as properties of the primordials object.
Static functions are prefixed by the constructor's name and prototype
methods are prefixed by the constructor's name followed by "Prototype".
For example: primordials.Object.keys becomes primordials.ObjectKeys.

PR-URL: https://github.com/nodejs/node/pull/30610
Refs: https://github.com/nodejs/node/issues/29766
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-25 10:28:15 +01:00
alexahdp
73780e33e3 net: replaced vars to lets and consts
PR-URL: https://github.com/nodejs/node/pull/30287
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-11-12 09:45:09 +00:00
Robert Nagy
d247a8e1dc http: emit close on socket re-use
PR-URL: https://github.com/nodejs/node/pull/28685
Refs: https://github.com/nodejs/node/issues/28684
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-10-15 16:51:09 -07:00
Robert Nagy
5f80df8820 http: do not emit end after aborted
IncomingMessage will no longer emit end after aborted.

PR-URL: https://github.com/nodejs/node/pull/27984
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-10-13 19:04:44 -07:00
themez
8915b15f8c http: add reusedSocket property on client request
Set ClientRequest.reusedSocket property when reusing socket for request,
so user can handle retry base on wether the request is reusing a socket.

Refs: https://github.com/request/request/issues/3131

PR-URL: https://github.com/nodejs/node/pull/29715
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Weijia Wang <starkwang@126.com>
2019-10-12 11:55:25 +08:00
ZYSzys
739f113ba6 lib: introduce no-mixed-operators eslint rule to lib
PR-URL: https://github.com/nodejs/node/pull/29834
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-10-05 13:59:32 -07:00
Robert Nagy
e573c39b88 http: don't emit 'data' after 'error'
PR-URL: https://github.com/nodejs/node/pull/28711
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-09-22 18:08:20 -07:00
Robert Nagy
627bb6bf87 http: refactor responseKeepAlive()
This tries to simplify the code and make it easier to understand. Took
me a while to get my head around the previous implementation.

Also minor perf improvement.

PR-URL: https://github.com/nodejs/node/pull/28700
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-09-15 21:50:03 -07:00
Robert Nagy
cad3a21c1d http: simplify timeout handling
Avoids allocating and registering extra listeners for 'timeout'.

PR-URL: https://github.com/nodejs/node/pull/29200
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-08-31 18:41:41 +02:00
Robert Nagy
f39ad8a91f http: fix event listener leak
Fixes: https://github.com/nodejs/node/issues/29239
PR-URL: https://github.com/nodejs/node/pull/29245
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-08-23 06:28:36 -07:00
Robert Nagy
bdf07f4317 http: simplify drain()
Simplify and slightly optimize draining outgoing http streams. Avoid
extra event listener and inline with rest of the drain logic.

PR-URL: https://github.com/nodejs/node/pull/29081
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-08-19 12:56:08 -07:00
Robert Nagy
0daec61b9b http: replace superfluous connection property with getter/setter
PR-URL: https://github.com/nodejs/node/pull/29015
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-17 06:21:59 -07:00
Robert Nagy
d30354859c http: follow symbol naming convention
PR-URL: https://github.com/nodejs/node/pull/29091
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-08-14 15:54:01 -07:00
Robert Nagy
2fd2dd7565 http: avoid extra listener
PR-URL: https://github.com/nodejs/node/pull/28705
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2019-07-18 20:58:54 -07:00
Austin Wright
d5737a8537 http: expose headers on an http.ClientRequest "information" event
1xx intermediate status responses are allowed to have headers; so
expose the "httpVersion", "httpVersionMajor", "httpVersionMinor",
"headers", "rawHeaders", and "statusMessage" properties on this
event.

PR-URL: https://github.com/nodejs/node/pull/28459
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-07-15 21:22:11 -07:00
Rich Trott
0796f0e268 Revert "http: fix test where aborted should not be emitted"
This reverts commit 461bf36d70.

PR-URL: https://github.com/nodejs/node/pull/28699
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-07-15 08:40:19 -07:00
Robert Nagy
461bf36d70 http: fix test where aborted should not be emitted
PR-URL: https://github.com/nodejs/node/pull/20077
Fixes: https://github.com/nodejs/node/issues/20107
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2019-07-14 21:48:21 -07:00
Anna Henningsen
ba565a3734 http: improve parser error messages
Include the library-provided reason in the Error’s `message`.

Fixes: https://github.com/nodejs/node/issues/28468

PR-URL: https://github.com/nodejs/node/pull/28487
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2019-07-05 22:36:53 -07:00
Luigi Pinca
d5577f0395 http: remove default 'timeout' listener on upgrade
Remove the default listener of the `'timeout'` event from the socket
before emitting the `'connect'` or `'upgrade'` event.

PR-URL: https://github.com/nodejs/node/pull/26030
Fixes: https://github.com/nodejs/node/issues/23857
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-08 13:35:37 +02:00
Robert Nagy
c6f545a74a http: fix deferToConnect comments
PR-URL: https://github.com/nodejs/node/pull/27876
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-06-02 11:06:03 +02:00
Rich Trott
aa8b820aaa errors: create internal connResetException
Replace various instances of errors that use code ECONNRESET with a
single centralized factory function to create the errors.

(While making changes to _tls_wrap.js, this also takes the opportunity
to make trailing commas consistent on multi-line arrays. One had a
trailing comma and one didn't. This adds a traiiling comma to the one
that didn't.)

PR-URL: https://github.com/nodejs/node/pull/27953
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2019-05-31 21:21:19 +02:00
Luigi Pinca
4fc0238a66
http: do not default to chunked encoding for TRACE
Fixes: https://github.com/nodejs/node/issues/25783

PR-URL: https://github.com/nodejs/node/pull/27673
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-05-20 00:05:15 +02:00
Gerhard Stoebich
8876ac5c35
async_hooks: fixup do not reuse HTTPParser
Fix some issues introduced/not fixed via
https://github.com/nodejs/node/pull/25094:
* Init hook is not emitted for a reused HTTPParser
* HTTPParser was still used as resource in init hook
* type used in init hook was always HTTPINCOMINGMESSAGE even for client
requests
* some tests have not been adapted to new resource names

With this change the async hooks init event is emitted during a call
to Initialize() as the type and resource object is available at this
time. As a result Initialize() must be called now which could be seen
as breaking change even HTTPParser is not part of documented API.

It was needed to put the ClientRequest instance into a wrapper object
instead passing it directly as async resource otherwise
test-domain-multi fails. I think this is because adding an EventEmitter
to a Domain adds a property 'domain' and the presence of this changes
the context propagation in domains.

Besides that tests still refering to resource HTTPParser have been
updated/improved.

Fixes: https://github.com/nodejs/node/issues/27467
Fixes: https://github.com/nodejs/node/issues/26961
Refs: https://github.com/nodejs/node/pull/25094

PR-URL: https://github.com/nodejs/node/pull/27477
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2019-05-03 16:02:55 +02:00
Daniel Beckert
ece507394a
src: do not reuse async resource in http parsers
Change resource being used, previously HTTParser was being reused.
We are now using IncomingMessage and ClientRequest objects.  The goal
here is to make the async resource unique for each async operatio

Refs: https://github.com/nodejs/node/pull/24330
Refs: https://github.com/nodejs/diagnostics/issues/248
Refs: https://github.com/nodejs/node/pull/21313

Co-authored-by: Matheus Marchini <mat@mmarchini.me>

PR-URL: https://github.com/nodejs/node/pull/25094
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benedikt Meurer <benedikt.meurer@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2019-04-22 11:51:46 -07:00
Michaël Zasso
908292cf1f lib: enforce the use of Object from primordials
PR-URL: https://github.com/nodejs/node/pull/27146
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
2019-04-12 05:38:45 +02:00
Anatoli Papirovski
47f5cc1ad1 lib: faster FreeList
Make FreeList faster by using Reflect.apply and not using
is_reused_symbol, but rather just checking whether any
items are present in the list prior to calling alloc.

PR-URL: https://github.com/nodejs/node/pull/27021
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-04-11 05:40:59 +02:00
Ruben Bridgewater
f86f5736da
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679

PR-URL: https://github.com/nodejs/node/pull/26915
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
2019-03-30 13:16:39 +01:00
Ruben Bridgewater
9e8c9be3ff
timers: rename validateTimerDuration to getTimerDuration
The function did not only validate the timer but it caused side
effects like a warning and potentially returned a different value
than the input value. Thus the name `validate` did not seem to be
appropriate.

PR-URL: https://github.com/nodejs/node/pull/26809
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-03-27 17:05:14 +01:00
Weijia Wang
c8d3a73c8b lib: use Array#includes instead of Array#indexOf
PR-URL: https://github.com/nodejs/node/pull/26732
Refs: https://github.com/nodejs/node/issues/26568
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2019-03-21 21:38:02 +08:00
James M Snell
f9ddbb6b2f
lib: move DTRACE_* probes out of global scope
The DTRACE_* probes have been global for no really good reason.
Move those into an internalBinding.

PR-URL: https://github.com/nodejs/node/pull/26541
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-03-12 14:19:36 +00:00
cjihrig
907941d48e
http: validate timeout in ClientRequest()
Validate the timeout option in the ClientRequest() constructor
to prevent asynchronously thrown validation errors.

PR-URL: https://github.com/nodejs/node/pull/26214
Fixes: https://github.com/nodejs/node/issues/26143
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2019-02-26 16:12:54 -05:00
cjihrig
a1d05e49fe
timers: support name in validateTimerDuration()
Allow passing a name to validateTimerDuration() so that error
messages can reflect the name of the thing being validated.

PR-URL: https://github.com/nodejs/node/pull/26215
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-22 13:39:21 -05:00
Weijia Wang
0b585457ee http: reduce multiple output arrays into one
Now we are using `output`, `outputEncodings` and `outputCallbacks`
to hold pending data. Reducing them into one array `outputData`
can slightly improve performance and reduce some redundant codes.

PR-URL: https://github.com/nodejs/node/pull/26004
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-11 13:35:58 +08:00
Rich Trott
62942e9ad7 lib: replace 'assert' with 'internal/assert' for many built-ins
Replace large 'assert' module with tiny 'internal/assert' module for
many built-in uses.

PR-URL: https://github.com/nodejs/node/pull/25956
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
2019-02-08 00:01:12 -08:00