summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* n-api: add error message for date expectedGabriel Schulhof2019-07-021-1/+2
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/28303 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* n-api: make func argument of napi_create_threadsafe_function optionallegendecas2019-07-021-4/+11
| | | | | | PR-URL: https://github.com/nodejs/node/pull/27791 Refs: https://github.com/nodejs/node/issues/27592 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
* src: add error codes to errors thrown in node_i18n.ccYaniv Friedensohn2019-07-021-2/+2
| | | | | | PR-URL: https://github.com/nodejs/node/pull/28221 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* report: add report versioningcjihrig2019-07-021-1/+2
| | | | | | | | This commit adds a version to the diagnostic report feature. PR-URL: https://github.com/nodejs/node/pull/28121 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
* src: refactor uncaught exception handlingJoyee Cheung2019-07-0210-109/+127
| | | | | | | | | | | | | | | | | | | | | | | | | | The C++ land `node::FatalException()` is not in fact fatal anymore. It gives the user a chance to handle the uncaught exception globally by listening to the `uncaughtException` event. This patch renames it to `TriggerUncaughtException` in C++ to avoid the confusion. In addition rename the JS land handler to `onGlobalUncaughtException` to reflect its purpose - we have to keep the alias `process._fatalException` and use that for now since it has been monkey-patchable in the user land. This patch also - Adds more comments to the global uncaught exception handling routine - Puts a few other C++ error handling functions into the `errors` namespace - Moves error-handling-related bindings to the `errors` binding. Refs: https://github.com/nodejs/node/commit/2b252acea47af3ebeac3d7e68277f015667264cc PR-URL: https://github.com/nodejs/node/pull/28257 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
* src: fall back to env->exec_path() for default profile directoryJoyee Cheung2019-07-021-10/+13
| | | | | | | | | When the current working directory is deleted, fall back to exec_path as the default profile directory. PR-URL: https://github.com/nodejs/node/pull/28252 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: save exec path when initializing EnvironmentJoyee Cheung2019-07-024-31/+42
| | | | | | PR-URL: https://github.com/nodejs/node/pull/28252 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
* crypto: fix crash when calling digest after pipingTobias Nießen2019-07-022-7/+18
| | | | | | | | | | | | | | | When piping data into an SHA3 hash, EVP_DigestFinal_ex is called in hash._flush, bypassing safeguards in the JavaScript layer. Calling hash.digest causes EVP_DigestFinal_ex to be called again, resulting in a segmentation fault in the SHA3 implementation of OpenSSL. A relatively easy solution is to cache the result of calling EVP_DigestFinal_ex until the Hash object is garbage collected. PR-URL: https://github.com/nodejs/node/pull/28251 Fixes: https://github.com/nodejs/node/issues/28245 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
* http2: refactor ping + settings object lifetime managementAnna Henningsen2019-07-024-55/+75
| | | | | | | | | | | | | | | | | | | Have clearer ownership relations between the `Http2Ping`, `Http2Settings` and `Http2Session` objects. Ping and Settings objects are now owned by the `Http2Session` instance, and deleted along with it, so neither type of object refers to the session after it is gone. In the case of `Http2Ping`s, that deletion is slightly delayed, so we explicitly reset its `session_` property. Fixes: https://github.com/nodejs/node/issues/28088 PR-URL: https://github.com/nodejs/node/pull/28150 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* Working on v12.5.1Ruben Bridgewater2019-06-271-2/+2
| | | | PR-URL: https://github.com/nodejs/node/pull/28268
* 2019-06-27, Version 12.5.0 (Current)v12.5.0v12.5.0-proposalRuben Bridgewater2019-06-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notable changes: * build: * The startup time is reduced by enabling V8 snapshots by default https://github.com/nodejs/node/pull/28181 * deps: * Updated `V8` to 7.5.288.22 https://github.com/nodejs/node/pull/27375 * The numeric separator (v8.dev/features/numeric-separators) feature is now enabled by default * Updated `OpenSSL` to 1.1.1c https://github.com/nodejs/node/pull/28211 * inspector: * The `--inspect-publish-uid` flag was added to specify ways of the inspector web socket url exposure https://github.com/nodejs/node/pull/27741 * n-api: * Accessors on napi_define_* are now ECMAScript-compliant https://github.com/nodejs/node/pull/27851 * report: * The cpu info got added to the report output https://github.com/nodejs/node/pull/28188 * src: * Restore the original state of the stdio file descriptors on exit to prevent leaving stdio in raw or non-blocking mode https://github.com/nodejs/node/pull/24260 * tools,gyp: * Introduce MSVS 2019 https://github.com/nodejs/node/pull/27375 * util: * inspect: * Array grouping became more compact and uses more columns than before https://github.com/nodejs/node/pull/28059 https://github.com/nodejs/node/pull/28070 * Long strings will not be split at 80 characters anymore. Instead they will be split on new lines https://github.com/nodejs/node/pull/28055 * worker: * `worker.terminate()` now returns a promise and using the callback is deprecated https://github.com/nodejs/node/pull/28021 PR-URL: https://github.com/nodejs/node/pull/28268
* worker: refactor `worker.terminate()`Anna Henningsen2019-06-182-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | At the collaborator summit in Berlin, the behaviour of `worker.terminate()` was discussed. In particular, switching from a callback-based to a Promise-based API was suggested. While investigating that possibility later, it was discovered that `.terminate()` was unintentionally synchronous up until now (including calling its callback synchronously). Also, the topic of its stability has been brought up. I have performed two manual reviews of the native codebase for compatibility with `.terminate()`, and performed some manual fuzz testing with the test suite. At this point, bugs with `.terminate()` should, in my opinion, be treated like bugs in other Node.js features. (It is possible to make Node.js crash with `.terminate()` by messing with internals and/or built-in prototype objects, but that is already the case without `.terminate()` as well.) This commit: - Makes `.terminate()` an asynchronous operation. - Makes `.terminate()` return a `Promise`. - Runtime-deprecates passing a callback. - Removes a warning about its stability from the documentation. - Eliminates an unnecessary extra function from the C++ code. A possible alternative to returning a `Promise` would be to keep the method synchronous and just drop the callback. Generally, providing an asynchronous API does provide us with a bit more flexibility. Refs: https://github.com/nodejs/summit/issues/141 PR-URL: https://github.com/nodejs/node/pull/28021 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* n-api: define ECMAScript-compliant accessors on napi_define_classlegendecas2019-06-181-33/+28
| | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/27851 Fixes: https://github.com/nodejs/node/issues/26551 Fixes: https://github.com/nodejs/node-addon-api/issues/485 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* n-api: define ECMAScript-compliant accessors on napi_define_propertieslegendecas2019-06-181-20/+50
| | | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/27851 Fixes: https://github.com/nodejs/node/issues/26551 Fixes: https://github.com/nodejs/node-addon-api/issues/485 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
* src: fix compiler warning in node_worker.ccDaniel Bevenius2019-06-181-0/+2
| | | | | | | | | | | | | | | | | | | | Currently, when configuring --without-ssl the following compiler warning is generated: ../src/node_worker.cc:192:10: warning: unused variable 'inspector_started' [-Wunused-variable] bool inspector_started = false; ^ 1 warning generated. This commit adds a macro guard to the variable to avoid the warning. PR-URL: https://github.com/nodejs/node/pull/28198 Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* report: add cpu info to report outputChristopher Hiller2019-06-181-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | The report shows CPU consumption %, but without the number of CPU cores, a consumer cannot tell if the percent (given across all cores) is actually problematic. E.g., 100% on one CPU is a problem, but 100% on four CPUs is not necessarily. This change adds CPU information (similar to `os.cpus()`) to the report output. Extra info besides the count is also provided as to avoid future breaking changes in the eventuality that someone needs it; changing the datatype of `header.cpus` would be breaking. PR-URL: https://github.com/nodejs/node/pull/28188 Refs: https://github.com/nodejs/diagnostics/issues/307 Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* n-api: defer Buffer finalizer with SetImmediateAnna Henningsen2019-06-181-10/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a test that verifies that JS execution from the Buffer finalizer is accepted, and that errors thrown are passed down synchronously. However, since the finalizer executes during GC, this is behaviour is fundamentally invalid and, for good reasons, disallowed by the JS engine. This leaves us with the options of either finding a way to allow JS execution from the callback, or explicitly forbidding it on the N-API side as well. This commit implements the former option, since it is the more backwards-compatible one, in the sense that the current situation sometimes appears to work as well and we should not break that behaviour if we don’t have to, but rather try to actually make it work reliably. Since GC timing is largely unobservable anyway, this commit moves the callback into a `SetImmediate()`, as we do elsewhere in the code, and a second pass callback is not an easily implemented option, as the API is supposed to wrap around Node’s `Buffer` API. In this case, exceptions are handled like other uncaught exceptions. Two tests have to be adjusted to account for the timing difference. This is unfortunate, but unavoidable if we want to conform to the JS engine API contract and keep all tests. Fixes: https://github.com/nodejs/node/issues/26754 PR-URL: https://github.com/nodejs/node/pull/28082 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: fix off-by-one error in native SetImmediateAnna Henningsen2019-06-181-0/+5
| | | | | | | | | | | | Previously, the throwing callback would have been re-executed in case of an exception. This patch corrects the calculation to exclude the callback. PR-URL: https://github.com/nodejs/node/pull/28082 Fixes: https://github.com/nodejs/node/issues/26754 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* worker: make MessagePort constructor non-callableAnna Henningsen2019-06-173-23/+17
| | | | | | | | | | | | | | Refactor the C++ code for creating `MessagePort`s to skip calling the constructor and instead directly instantiating the `InstanceTemplate`, and always throw an error from the `MessagePort` constructor. This aligns behaviour with the web, and creating single `MessagePort`s does not make sense anyway. PR-URL: https://github.com/nodejs/node/pull/28032 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
* src: do not use pointer for loop in node_watchdogAnna Henningsen2019-06-172-13/+9
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/28020 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* src: restore stdio on program exitBen Noordhuis2019-06-174-7/+90
| | | | | | | | | | | | | | | | | | | | | | | | Record the state of the stdio file descriptors on start-up and restore them to that state on exit. This should prevent issues where node.js sometimes leaves stdio in raw or non-blocking mode. This is a reworked version of commit c2c9c0c3d3 from May 2018 that was reverted in commit 14dc17df38 from June 2018. The revert was a little light on details but I infer that the problem was caused by a missing call to `uv_tty_reset_mode()`. Apropos the NOLINT comments: cpplint doesn't understand do/while statements, it thinks they're while statements without a body. Fixes: https://github.com/nodejs/node/issues/14752 Fixes: https://github.com/nodejs/node/issues/21020 Original-PR-URL: https://github.com/nodejs/node/pull/20592 PR-URL: https://github.com/nodejs/node/pull/24260 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann (רפאל פלחי) <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: remove TLS code for unsupported OpenSSLsSam Roberts2019-06-173-61/+7
| | | | | | | | | | | | Versions of OpenSSL lower than 1.1.1 are no longer supported, so remove ifdefs for previous versions. PR-URL: https://github.com/nodejs/node/pull/28085 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* worker: add typechecking for postMessage transfer listAnna Henningsen2019-06-171-0/+9
| | | | | | | | | | | | If the transfer list argument is present, it should be an array. This commit adds typechecking to that effect. This aligns behaviour with browsers. PR-URL: https://github.com/nodejs/node/pull/28033 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* worker: use DataCloneError for unknown native objectsAnna Henningsen2019-06-173-3/+2
| | | | | | | | | | | This aligns the behaviour better with the web. PR-URL: https://github.com/nodejs/node/pull/28025 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
* src: handle exceptions from ToDetailString()Anna Henningsen2019-06-172-3/+6
| | | | | | | | | | | These methods may fail if execution is terminating. PR-URL: https://github.com/nodejs/node/pull/28019 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* src: expose DOMException to internalBinding('message') for testingJoyee Cheung2019-06-171-11/+23
| | | | | | | | Instead of using a hack to get it in the test. PR-URL: https://github.com/nodejs/node/pull/28072 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
* src: add napi_define_class() null checksOctavian Soldea2019-06-171-0/+7
| | | | | | | | | | napi_define_class is tested by passing NULL to all parameters that are pointers, one at a time. Moreover, two bugs were corrected. One was utf8name and the second was the property descriptor pointer. These pointers were assumed to be non-NULL and now we have NULL checks. PR-URL: https://github.com/nodejs/node/pull/27945 Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
* src: use RAII in setgroups implementationAnna Henningsen2019-06-171-4/+2
| | | | | | | | | Prefer `MaybeStackBuffer` over manual memory management. PR-URL: https://github.com/nodejs/node/pull/28022 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* src: fix unused private field warningcjihrig2019-06-173-5/+4
| | | | | | | | | PR-URL: https://github.com/nodejs/node/pull/28036 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
* src: split `RunBootstrapping()`Joyee Cheung2019-06-176-68/+82
| | | | | | | | | Split `RunBootstrapping()` into `BootstrapInternalLoaders()` and `BootstrapNode()` from so the two can be snapshotted incrementally. PR-URL: https://github.com/nodejs/node/pull/27539 Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: reorganize inspector and diagnostics initializationJoyee Cheung2019-06-177-55/+74
| | | | | | | | | | | | | | | | - Split the initialization of the inspector and other diagnostics into `Environment::InitializeInspector()` and `Environment::InitializeDiagnostics()` - these need to be reinitialized separately after snapshot deserialization. - Do not store worker url alongside the inspector parent handle, instead just get it from the handle. - Rename `Worker::profiler_idle_notifier_started_` to `Worker::start_profiler_idle_notifier_` because it stores the state inherited from the parent env to use for initializing itself. PR-URL: https://github.com/nodejs/node/pull/27539 Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: create Environment properties in Environment::CreateProperties()Joyee Cheung2019-06-173-22/+31
| | | | | | | | | | | Move creation of `env->as_callback_data()`, `env->primordials()` and `env->process()` into `Environment::CreateProperties()` and call it in the `Environment` constructor - this can be replaced with deserialization when we snapshot the per-environment properties after the instantiation of `Environment`. PR-URL: https://github.com/nodejs/node/pull/27539 Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: inline ProcessCliArgs in the Environment constructorJoyee Cheung2019-06-177-43/+32
| | | | | | | | | | | Inline `ProcessCliArgs()` in the `Environment` constructor, and emit the `Environment` creation trace events with the arguments earlier. Remove the unused arguments passed to `CreateProcessObject()` since these are now attached to process in `PatchProcessObject()` during pre-execution instead. PR-URL: https://github.com/nodejs/node/pull/27539 Reviewed-By: Anna Henningsen <anna@addaleax.net>
* inspector: added --inspect-publish-uidAleksei Koziatinskii2019-06-177-21/+93
| | | | | | | | | | | | | | | This flag specifies how inspector websocket url should be reported. Tthre options are supported: - stderr - reports websocket as a message to stderr, - http - exposes /json/list endpoint that contains inspector websocket url, - binding - require('inspector').url(). Related discussion: https://github.com/nodejs/diagnostics/issues/303 PR-URL: https://github.com/nodejs/node/pull/27741 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
* Working on v12.4.1Michaël Zasso2019-06-041-2/+2
| | | | PR-URL: https://github.com/nodejs/node/pull/28040
* 2019-06-04, Version 12.4.0 (Current)v12.4.0v12.4.0-proposalMichaël Zasso2019-06-031-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notable changes: * doc: * The JSON variant of the API documentation is no longer experimental (Rich Trott) https://github.com/nodejs/node/pull/27842. * esm: * JSON module support is always enabled under `--experimental-modules`. The `--experimental-json-modules` flag has been removed (Myles Borins) https://github.com/nodejs/node/pull/27752. * http,http2: * A new flag has been added for overriding the default HTTP server socket timeout (which is two minutes). Pass `--http-server-default-timeout=milliseconds` or `--http-server-default-timeout=0` to respectively change or disable the timeout. Starting with Node.js 13.0.0, the timeout will be disabled by default (Ali Ijaz Sheikh) https://github.com/nodejs/node/pull/27704. * inspector: * Added an experimental `--heap-prof` flag to start the V8 heap profiler on startup and write the heap profile to disk before exit (Joyee Cheung) https://github.com/nodejs/node/pull/27596. * stream: * The `readable.unshift()` method now correctly converts strings to buffers. Additionally, a new optional argument is accepted to specify the string's encoding, such as `'utf8'` or `'ascii'` (Marcos Casagrande) https://github.com/nodejs/node/pull/27194. * v8: * The object returned by `v8.getHeapStatistics()` has two new properties: `number_of_native_contexts` and `number_of_detached_contexts` (Yuriy Vasiyarov) https://github.com/nodejs/node/pull/27933. PR-URL: https://github.com/nodejs/node/pull/28040
* inspector: supported NodeRuntime domain in workerAleksei Koziatinskii2019-06-035-10/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | NodeRuntime domain was introduced to give inspector client way to fetch captured information before Node process is gone. We need similar capability for work. With current protocol inspector client can force worker to wait on start by passing waitForDebuggerOnStart flag to NodeWorker.enable method. So client has some time to setup environment, e.g. start profiler. At the same time there is no way to prevent worker from being terminated. So we can start capturing profile but we can not reliably get captured data back. This PR implemented NodeRuntime.notifyWhenWaitingForDisconnect method for worker. When NodeRuntime.waitingForDisconnect notification is enabled, worker will wait for explicit NodeWorker.detach call. With this PR worker tooling story is nicely aligned with main thread tooling story. The only difference is that main thread by default is waiting for disconnect but worker thread is not waiting. Issue: https://github.com/nodejs/node/issues/27677 PR-URL: https://github.com/nodejs/node/pull/27706 Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
* tools: fix js2c regressionRefael Ackermann2019-06-021-0/+5
| | | | | | | PR-URL: https://github.com/nodejs/node/pull/27980 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
* inspector: more conservative minimum stack sizeBen Noordhuis2019-06-021-6/+13
| | | | | | | | | | | | | | PTHREAD_STACK_MIN is 2 KB with musl, which is too small to safely receive signals. PTHREAD_STACK_MIN + MINSIGSTKSZ is 8 KB on arm64, which is the musl architecture with the biggest MINSIGSTKSZ so let's use that as a lower bound and let's quadruple it just in case. PR-URL: https://github.com/nodejs/node/pull/27855 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com>
* tools: update inspector_protocol to 0aafd2Michaël Zasso2019-06-014-12/+28
| | | | | | | | Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/nodejs/node/pull/27770 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* src: unimplement deprecated v8-platform methodsMichaël Zasso2019-05-312-14/+8
| | | | | | | | | | | | | This removes the implementations of NodePlatform::CallOnForegroundThread and NodePlatform::CallDelayedOnForegroundThread and updates the test_platform cctest to stop using them. PR-URL: https://github.com/nodejs/node/pull/27872 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* src: export number_of_native_contexts and number_of_detached_contextsYuriy Vasiyarov2019-05-311-1/+3
| | | | | | | | | | | | export number_of_native_contexts and number_of_detached_contexts as part of v8.getHeapStatistics() PR-URL: https://github.com/nodejs/node/pull/27933 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* tls: trace errors can show up as SSL errorsSam Roberts2019-05-311-1/+11
| | | | | | | | | | | | | | | | Calls to TLS_trace might leave errors on the SSL error stack, which then get reported as SSL errors instead of being ignored. Wrap TLS_trace to keep the error stack unchanged. Fixes: https://github.com/nodejs/node/issues/27636 PR-URL: https://github.com/nodejs/node/pull/27841 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
* src: use ArrayBufferViewContents more frequentlyAnna Henningsen2019-05-319-81/+77
| | | | | | | | | | | | | Using `ArrayBufferViewContents` over `Buffer::Data()`/`Buffer::Length()` or `SPREAD_BUFFER_ARG` has the advantages of creating fewer individual variables to keep track off, not being a “magic” macro that creates variables, reducing code size, and being faster when receiving on-heap TypedArrays. PR-URL: https://github.com/nodejs/node/pull/27920 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
* src: make UNREACHABLE variadicRefael Ackermann2019-05-311-2/+2
| | | | | | | | | Eliminate warning C4003 - not enough arguments for function-like macro invocation 'UNREACHABLE' PR-URL: https://github.com/nodejs/node/pull/27877 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
* tls: group chunks into TLS segmentsAlba Mendez2019-05-312-46/+46
| | | | | | | | | | | | | | | | | | | | | | | | TLSWrap::DoWrite() now concatenates data chunks and makes a single call to SSL_write(). Grouping data into a single segment: - reduces network overhead: by factors of even 2 or 3 in usages like `http2` or `form-data` - improves security: segment lengths can reveal lots of info, i.e. with `form-data`, how many fields are sent and the approximate length of every individual field and its headers - reduces encryption overhead: a quick benchmark showed a ~30% CPU time decrease for an extreme case, see https://github.com/nodejs/node/issues/27573#issuecomment-493787867 Fixes: https://github.com/nodejs/node/issues/27573 PR-URL: https://github.com/nodejs/node/pull/27861 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* http2: fix tracking received data for maxSessionMemoryAnna Henningsen2019-05-311-2/+4
| | | | | | | | | | | | | | | | Track received data correctly. Specifically, for the buffer that is used for receiving data, we previously would try to increment the current memory usage by its length, and later decrement it by that, but in the meantime the buffer had been turned over to V8 and its length reset to zero. This gave the impression that more and more memory was consumed by the HTTP/2 session when it was in fact not. Fixes: https://github.com/nodejs/node/issues/27416 Refs: https://github.com/nodejs/node/pull/26207 PR-URL: https://github.com/nodejs/node/pull/27914 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* inspector: implement --heap-profJoyee Cheung2019-05-286-0/+168
| | | | | | | | | | | | In addition implements --heap-prof-name, --heap-prof-dir and --heap-prof-interval. These flags are similar to --cpu-prof flags but they are meant for the V8 sampling heap profiler instead of the CPU profiler. PR-URL: https://github.com/nodejs/node/pull/27596 Fixes: https://github.com/nodejs/node/issues/27421 Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
* src: move DiagnosticFilename inlines into a -inl.hSam Roberts2019-05-2813-19/+45
| | | | | | | | | | | | DiagnosticFilename's constructor default values use inlines from env-inl.h, causing the many users of node_internals.h to include env-inl.h, even if they never use DiagnosticFilename. PR-URL: https://github.com/nodejs/node/pull/27839 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
* os: assume UTF-8 for hostnameAnna Henningsen2019-05-281-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Do not assume Latin-1, but rather UTF-8 for the result of getting the OS hostname. While in 99 % of cases these strings are stored in ASCII, the OS does not enforce an encoding on its own, and apparently the hostname is sometimes set to non-ASCII data (despite at least some versions of hostname(1) rejecting such input, making it even harder to write a test for this which would already require root privileges). In any case, these are short strings, so assuming UTF-8 comes with no significant overhead. Fixes: https://github.com/nodejs/node/issues/27848 PR-URL: https://github.com/nodejs/node/pull/27849 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>