diff --git a/.eslintrc.js b/.eslintrc.js index 6a378f659c8..2250fdba77e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -58,12 +58,12 @@ module.exports = { 'dot-location': ['error', 'property'], 'dot-notation': 'error', 'eol-last': 'error', - eqeqeq: ['error', 'smart'], + 'eqeqeq': ['error', 'smart'], 'for-direction': 'error', 'func-call-spacing': 'error', 'func-name-matching': 'error', 'func-style': ['error', 'declaration', { allowArrowFunctions: true }], - indent: ['error', 2, { + 'indent': ['error', 2, { ArrayExpression: 'first', CallExpression: { arguments: 'first' }, FunctionDeclaration: { parameters: 'first' }, @@ -209,9 +209,10 @@ module.exports = { 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], 'prefer-const': ['error', { ignoreReadBeforeAssign: true }], - quotes: ['error', 'single', { avoidEscape: true }], + 'quotes': ['error', 'single', { avoidEscape: true }], + 'quote-props': ['error', 'consistent'], 'rest-spread-spacing': 'error', - semi: 'error', + 'semi': 'error', 'semi-spacing': 'error', 'space-before-blocks': ['error', 'always'], 'space-before-function-paren': ['error', { @@ -222,7 +223,7 @@ module.exports = { 'space-in-parens': ['error', 'never'], 'space-infix-ops': 'error', 'space-unary-ops': 'error', - strict: ['error', 'global'], + 'strict': ['error', 'global'], 'symbol-description': 'error', 'template-curly-spacing': 'error', 'unicode-bom': 'error', diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e90c6d4696..a8f3e2025a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,9 @@ release. -9.7.0
+9.8.0
+9.7.1
+9.7.0
9.6.1
9.6.0
9.5.0
diff --git a/benchmark/querystring/querystring-stringify.js b/benchmark/querystring/querystring-stringify.js index cd1debd4df6..9f025c922ad 100644 --- a/benchmark/querystring/querystring-stringify.js +++ b/benchmark/querystring/querystring-stringify.js @@ -17,7 +17,7 @@ function main({ type, n }) { encodemany: { '\u0080\u0083\u0089': 'bar', '\u008C\u008E\u0099': 'quux', - xyzzy: '\u00A5q\u00A3r' + 'xyzzy': '\u00A5q\u00A3r' }, encodelast: { foo: 'bar', diff --git a/doc/api/cli.md b/doc/api/cli.md index 2a1474f33ff..840a6cad3b6 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -237,7 +237,7 @@ tracing is enabled using `--trace-events-enabled`. ### `--trace-event-file-pattern` Template string specifying the filepath for the trace event data, it diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 4eb90c4c38c..b3b316f1a35 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -915,7 +915,6 @@ Type: Runtime This was never a documented feature. - ### DEP0101: --with-lttng @@ -940,6 +939,17 @@ Type: Documentation-only (supports [`--pending-deprecation`][]) Using `process.binding()` in general should be avoided. The type checking methods in particular can be replaced by using [`util.types`][]. + +### DEP0104: process.env string coercion + +Type: Documentation-only (supports [`--pending-deprecation`][]) + +Currently when assigning a property to [`process.env`][], the assigned value is +implicitly converted to a string if it is not a string. This behavior is +deprecated if the assigned value is not a string, boolean, or number. In the +future, such assignment may result in a thrown error. Please convert the +property to a string before assigning it to `process.env`. + [`--pending-deprecation`]: cli.html#cli_pending_deprecation [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array @@ -976,6 +986,7 @@ methods in particular can be replaced by using [`util.types`][]. [`fs.stat()`]: fs.html#fs_fs_stat_path_callback [`os.networkInterfaces`]: os.html#os_os_networkinterfaces [`os.tmpdir()`]: os.html#os_os_tmpdir +[`process.env`]: process.html#process_process_env [`punycode`]: punycode.html [`require.extensions`]: modules.html#modules_require_extensions [`setInterval()`]: timers.html#timers_setinterval_callback_delay_args diff --git a/doc/api/inspector.md b/doc/api/inspector.md index b6f702f0dd5..c801510b756 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -136,8 +136,34 @@ with an error. [`session.connect()`] will need to be called to be able to send messages again. Reconnected session will lose all inspector state, such as enabled agents or configured breakpoints. +## Example usage + +### CPU Profiler + +Apart from the debugger, various V8 Profilers are available through the DevTools +protocol. Here's a simple example showing how to use the [CPU profiler][]: + +```js +const inspector = require('inspector'); + +const session = new inspector.Session(); +session.connect(); + +session.post('Profiler.enable', () => { + session.post('Profiler.start', () => { + // invoke business logic under measurement here... + + // some time later... + session.post('Profiler.stop', ({ profile }) => { + // write profile to disk, upload, etc. + }); + }); +}); +``` + [`session.connect()`]: #inspector_session_connect [`Debugger.paused`]: https://chromedevtools.github.io/devtools-protocol/v8/Debugger/#event-paused [`EventEmitter`]: events.html#events_class_eventemitter [Chrome DevTools Protocol Viewer]: https://chromedevtools.github.io/devtools-protocol/v8/ +[CPU Profiler]: https://chromedevtools.github.io/devtools-protocol/v8/Profiler diff --git a/doc/api/process.md b/doc/api/process.md index 2bd7a119bf8..e89e5c0281a 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -836,6 +836,10 @@ emitMyWarning(); ## process.env * {Object} @@ -877,7 +881,8 @@ console.log(process.env.foo); ``` Assigning a property on `process.env` will implicitly convert the value -to a string. +to a string. **This behavior is deprecated.** Future versions of Node.js may +throw an error when the value is not a string, number, or boolean. Example: diff --git a/doc/api/repl.md b/doc/api/repl.md index c868106f2f9..233977fe09c 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -144,7 +144,7 @@ global or scoped variable, the input `fs` will be evaluated on-demand as #### Assignment of the `_` (underscore) variable diff --git a/doc/changelogs/CHANGELOG_V9.md b/doc/changelogs/CHANGELOG_V9.md index 37b34de0dc6..d4ad1d9cbc8 100644 --- a/doc/changelogs/CHANGELOG_V9.md +++ b/doc/changelogs/CHANGELOG_V9.md @@ -9,6 +9,7 @@ +9.8.0
9.7.1
9.7.0
9.6.1
@@ -35,6 +36,99 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2018-03-07, Version 9.8.0 (Current), @MylesBorins + +### Notable Changes + +* **crypto**: + - add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson) [#17690](https://github.com/nodejs/node/pull/17690) +* **http2**: + - Fixed issues with aborted connections in the HTTP/2 implementation (Anna Henningsen) [#18987](https://github.com/nodejs/node/pull/18987) [#19002](https://github.com/nodejs/node/pull/19002) +* **loader**: + - --inspect-brk now works properly for esmodules (Gus Caplan) [#18949](https://github.com/nodejs/node/pull/18949) +* **src**: + - make process.dlopen() load well-known symbol (Ben Noordhuis) [#18934](https://github.com/nodejs/node/pull/18934) +* **trace_events**: + - add file pattern cli option (Andreas Madsen) [#18480](https://github.com/nodejs/node/pull/18480) +* **Added new collaborators** + - [MoonBall](https://github.com/MoonBall) Chen Gang + +### Commits + +* [[`6ae2cafde3`](https://github.com/nodejs/node/commit/6ae2cafde3)] - **buffer**: coerce offset to integer (Ruben Bridgewater) [#18215](https://github.com/nodejs/node/pull/18215) +* [[`6d17383041`](https://github.com/nodejs/node/commit/6d17383041)] - **buffer**: fix typo in lib/buffer.js (Ujjwal Sharma) [#19126](https://github.com/nodejs/node/pull/19126) +* [[`4b34b2e185`](https://github.com/nodejs/node/commit/4b34b2e185)] - **build**: fix gocvr version used for coverage (Michael Dawson) [#19094](https://github.com/nodejs/node/pull/19094) +* [[`a938e52ffe`](https://github.com/nodejs/node/commit/a938e52ffe)] - **build**: disable openssl build warnings on macos (Ben Noordhuis) [#19046](https://github.com/nodejs/node/pull/19046) +* [[`44d80c5620`](https://github.com/nodejs/node/commit/44d80c5620)] - **build**: fix coverage after gcovr update (killagu) [#18958](https://github.com/nodejs/node/pull/18958) +* [[`28a5362e83`](https://github.com/nodejs/node/commit/28a5362e83)] - **build**: fix lint-md-build dependency (Joyee Cheung) [#18981](https://github.com/nodejs/node/pull/18981) +* [[`e74e422a53`](https://github.com/nodejs/node/commit/e74e422a53)] - **(SEMVER-MINOR)** **crypto**: add cert.fingerprint256 as SHA256 fingerprint (Hannes Magnusson) [#17690](https://github.com/nodejs/node/pull/17690) +* [[`056001dc8f`](https://github.com/nodejs/node/commit/056001dc8f)] - **(SEMVER-MINOR)** **deps**: cherry-pick 0bcb1d6f from upstream V8 (Jakob Kummerow) [#18212](https://github.com/nodejs/node/pull/18212) +* [[`1fadb2edb4`](https://github.com/nodejs/node/commit/1fadb2edb4)] - **doc**: fix/add link to Android info (Vse Mozhet Byt) [#19004](https://github.com/nodejs/node/pull/19004) +* [[`68524610f2`](https://github.com/nodejs/node/commit/68524610f2)] - **doc**: remove subsystem from pull request template (Rich Trott) [#19125](https://github.com/nodejs/node/pull/19125) +* [[`d3a70e9cd4`](https://github.com/nodejs/node/commit/d3a70e9cd4)] - **doc**: remove tentativeness in pull-requests.md (Rich Trott) [#19123](https://github.com/nodejs/node/pull/19123) +* [[`f03079fce6`](https://github.com/nodejs/node/commit/f03079fce6)] - **doc**: update cc list (Ruben Bridgewater) [#19099](https://github.com/nodejs/node/pull/19099) +* [[`9d2de16b13`](https://github.com/nodejs/node/commit/9d2de16b13)] - **doc**: add introduced\_in metadata to \_toc.md (Rich Trott) [#19113](https://github.com/nodejs/node/pull/19113) +* [[`ae2dabb8fc`](https://github.com/nodejs/node/commit/ae2dabb8fc)] - **doc**: new team for bundlers or delivery of Node.js (Michael Dawson) [#19098](https://github.com/nodejs/node/pull/19098) +* [[`0e4f4266a1`](https://github.com/nodejs/node/commit/0e4f4266a1)] - **doc**: add simple example to rename function (punteek) [#18812](https://github.com/nodejs/node/pull/18812) +* [[`e42600fc4b`](https://github.com/nodejs/node/commit/e42600fc4b)] - **doc**: add missing `Returns` in fs & util (Sho Miyamoto) [#18775](https://github.com/nodejs/node/pull/18775) +* [[`4ecf5bbe74`](https://github.com/nodejs/node/commit/4ecf5bbe74)] - **doc**: fix a typo in util.isDeepStrictEqual (Sho Miyamoto) [#18775](https://github.com/nodejs/node/pull/18775) +* [[`cab6c8e95c`](https://github.com/nodejs/node/commit/cab6c8e95c)] - **doc**: add URL.format() example (Zeke Sikelianos) [#18888](https://github.com/nodejs/node/pull/18888) +* [[`a4462b7944`](https://github.com/nodejs/node/commit/a4462b7944)] - **doc**: fix n-api asynchronous threading docs (Eric Bickle) [#19073](https://github.com/nodejs/node/pull/19073) +* [[`bfa894cf37`](https://github.com/nodejs/node/commit/bfa894cf37)] - **doc**: add MoonBall to collaborators (Chen Gang) [#19109](https://github.com/nodejs/node/pull/19109) +* [[`77154cd65d`](https://github.com/nodejs/node/commit/77154cd65d)] - **doc**: update list of re-exported symbols (Richard Lau) [#19013](https://github.com/nodejs/node/pull/19013) +* [[`459f2095a1`](https://github.com/nodejs/node/commit/459f2095a1)] - **doc**: Readable unpipe on Writable error event (George Sapkin) [#18080](https://github.com/nodejs/node/pull/18080) +* [[`68c1337819`](https://github.com/nodejs/node/commit/68c1337819)] - **doc**: add RegExp Unicode Property Escapes to intl (Vse Mozhet Byt) [#19052](https://github.com/nodejs/node/pull/19052) +* [[`71d09ecbf1`](https://github.com/nodejs/node/commit/71d09ecbf1)] - **doc**: make the background section concise and improve its formality (Wilson) [#18928](https://github.com/nodejs/node/pull/18928) +* [[`951054004d`](https://github.com/nodejs/node/commit/951054004d)] - **doc**: lowercase primitives in test/common/README.md (Vse Mozhet Byt) [#18875](https://github.com/nodejs/node/pull/18875) +* [[`5b8c97f6bc`](https://github.com/nodejs/node/commit/5b8c97f6bc)] - **events**: show throw stack trace for uncaught exception (Anna Henningsen) [#19003](https://github.com/nodejs/node/pull/19003) +* [[`0789eeceb6`](https://github.com/nodejs/node/commit/0789eeceb6)] - **http**: prevent aborted event when already completed (Andrew Johnston) [#18999](https://github.com/nodejs/node/pull/18999) +* [[`ae4d83facf`](https://github.com/nodejs/node/commit/ae4d83facf)] - **http**: prevent aborted event when already completed (Andrew Johnston) [#18999](https://github.com/nodejs/node/pull/18999) +* [[`50d1233935`](https://github.com/nodejs/node/commit/50d1233935)] - **http2**: no stream destroy while its data is on the wire (Anna Henningsen) [#19002](https://github.com/nodejs/node/pull/19002) +* [[`551d9752c8`](https://github.com/nodejs/node/commit/551d9752c8)] - **http2**: fix flaky test-http2-https-fallback (Matteo Collina) [#19093](https://github.com/nodejs/node/pull/19093) +* [[`8bc930c269`](https://github.com/nodejs/node/commit/8bc930c269)] - **http2**: fix endless loop when writing empty string (Anna Henningsen) [#18924](https://github.com/nodejs/node/pull/18924) +* [[`aa0fca9426`](https://github.com/nodejs/node/commit/aa0fca9426)] - **http2**: use original error for cancelling pending streams (Anna Henningsen) [#18988](https://github.com/nodejs/node/pull/18988) +* [[`447136999d`](https://github.com/nodejs/node/commit/447136999d)] - **http2**: send error text in case of ALPN mismatch (Anna Henningsen) [#18986](https://github.com/nodejs/node/pull/18986) +* [[`ef8f90f34e`](https://github.com/nodejs/node/commit/ef8f90f34e)] - **http2**: fix condition where data is lost (Matteo Collina) [#18895](https://github.com/nodejs/node/pull/18895) +* [[`e584113b66`](https://github.com/nodejs/node/commit/e584113b66)] - **lib**: re-fix v8\_prof\_processor (Anna Henningsen) [#19059](https://github.com/nodejs/node/pull/19059) +* [[`12856b0dd2`](https://github.com/nodejs/node/commit/12856b0dd2)] - **lib**: change hook -\> hooks in code comment (Daniel Bevenius) [#19053](https://github.com/nodejs/node/pull/19053) +* [[`db8d197e79`](https://github.com/nodejs/node/commit/db8d197e79)] - **lib,test**: remove yoda statements (Ruben Bridgewater) [#18746](https://github.com/nodejs/node/pull/18746) +* [[`59547cc438`](https://github.com/nodejs/node/commit/59547cc438)] - **loader**: fix --inspect-brk (Gus Caplan) [#18949](https://github.com/nodejs/node/pull/18949) +* [[`39e032fe86`](https://github.com/nodejs/node/commit/39e032fe86)] - **module**: fix main lookup regression from #18728 (Guy Bedford) [#18788](https://github.com/nodejs/node/pull/18788) +* [[`f3e3429296`](https://github.com/nodejs/node/commit/f3e3429296)] - **module**: support main w/o extension, pjson cache (Guy Bedford) [#18728](https://github.com/nodejs/node/pull/18728) +* [[`95f6467ffd`](https://github.com/nodejs/node/commit/95f6467ffd)] - **module**: fix cyclical dynamic import (Bradley Farias) [#18965](https://github.com/nodejs/node/pull/18965) +* [[`5c4f703607`](https://github.com/nodejs/node/commit/5c4f703607)] - **n-api**: update reference test (Gabriel Schulhof) [#19086](https://github.com/nodejs/node/pull/19086) +* [[`1b32fc3276`](https://github.com/nodejs/node/commit/1b32fc3276)] - **n-api**: fix object test (Gabriel Schulhof) [#19039](https://github.com/nodejs/node/pull/19039) +* [[`ef4714c2b6`](https://github.com/nodejs/node/commit/ef4714c2b6)] - **net**: inline and simplify onSocketEnd (Anna Henningsen) [#18607](https://github.com/nodejs/node/pull/18607) +* [[`28880cf89d`](https://github.com/nodejs/node/commit/28880cf89d)] - **perf_hooks**: fix timing (Timothy Gu) [#18993](https://github.com/nodejs/node/pull/18993) +* [[`96f0bec48b`](https://github.com/nodejs/node/commit/96f0bec48b)] - **repl**: make last error available as `\_error` (Anna Henningsen) [#18919](https://github.com/nodejs/node/pull/18919) +* [[`420d56c2ea`](https://github.com/nodejs/node/commit/420d56c2ea)] - **src**: don't touch js object in Http2Session dtor (Ben Noordhuis) [#18656](https://github.com/nodejs/node/pull/18656) +* [[`f89f659dcf`](https://github.com/nodejs/node/commit/f89f659dcf)] - **src**: remove unnecessary Reset() calls (Ben Noordhuis) [#18656](https://github.com/nodejs/node/pull/18656) +* [[`67a9742aed`](https://github.com/nodejs/node/commit/67a9742aed)] - **src**: prevent persistent handle resource leaks (Ben Noordhuis) [#18656](https://github.com/nodejs/node/pull/18656) +* [[`08bcdde888`](https://github.com/nodejs/node/commit/08bcdde888)] - **(SEMVER-MINOR)** **src**: handle exceptions in env-\>SetImmediates (James M Snell) [#18297](https://github.com/nodejs/node/pull/18297) +* [[`cc52dae7c4`](https://github.com/nodejs/node/commit/cc52dae7c4)] - **src**: #include \" to iculslocs (Steven R. Loomis) [#19150](https://github.com/nodejs/node/pull/19150) +* [[`2f17c52674`](https://github.com/nodejs/node/commit/2f17c52674)] - **src**: use std::unique\_ptr for STACK\_OF(X509) (Ben Noordhuis) [#19087](https://github.com/nodejs/node/pull/19087) +* [[`f10470ce2d`](https://github.com/nodejs/node/commit/f10470ce2d)] - **src**: refactor GetPeerCertificate (Daniel Bevenius) [#19087](https://github.com/nodejs/node/pull/19087) +* [[`4fae6e3904`](https://github.com/nodejs/node/commit/4fae6e3904)] - **(SEMVER-MINOR)** **src**: make process.dlopen() load well-known symbol (Ben Noordhuis) [#18934](https://github.com/nodejs/node/pull/18934) +* [[`89edbae7ab`](https://github.com/nodejs/node/commit/89edbae7ab)] - **(SEMVER-MINOR)** **src**: clean up process.dlopen() (Ben Noordhuis) [#18934](https://github.com/nodejs/node/pull/18934) +* [[`08b83ee27a`](https://github.com/nodejs/node/commit/08b83ee27a)] - **src**: refactor setting JS properties on WriteWrap (Anna Henningsen) [#18963](https://github.com/nodejs/node/pull/18963) +* [[`4d5cd5c6c5`](https://github.com/nodejs/node/commit/4d5cd5c6c5)] - **src**: fix error message in async\_hooks constructor (Daniel Bevenius) [#19000](https://github.com/nodejs/node/pull/19000) +* [[`6787913a68`](https://github.com/nodejs/node/commit/6787913a68)] - **test**: add more information to assert.strictEqual (Ujjwal Sharma) [#19162](https://github.com/nodejs/node/pull/19162) +* [[`ee653ecd09`](https://github.com/nodejs/node/commit/ee653ecd09)] - **test**: move require http2 to after crypto check (Daniel Bevenius) [#19111](https://github.com/nodejs/node/pull/19111) +* [[`5bbf009c1d`](https://github.com/nodejs/node/commit/5bbf009c1d)] - **test**: check symbols in shared lib (Yihong Wang) [#18806](https://github.com/nodejs/node/pull/18806) +* [[`d8833762cb`](https://github.com/nodejs/node/commit/d8833762cb)] - **test**: refactor test-async-wrap-getasyncid (Santiago Gimeno) [#18727](https://github.com/nodejs/node/pull/18727) +* [[`23107ba7b1`](https://github.com/nodejs/node/commit/23107ba7b1)] - **test**: remove assert message and add block scope (wuweiweiwu) [#19054](https://github.com/nodejs/node/pull/19054) +* [[`cc90bbd0f4`](https://github.com/nodejs/node/commit/cc90bbd0f4)] - **test**: fix flaky inspector-stop-profile-after-done (Rich Trott) [#18126](https://github.com/nodejs/node/pull/18126) +* [[`8d595bb25c`](https://github.com/nodejs/node/commit/8d595bb25c)] - **test**: check endless loop while writing empty string (XadillaX) [#18924](https://github.com/nodejs/node/pull/18924) +* [[`a4550069ca`](https://github.com/nodejs/node/commit/a4550069ca)] - **test**: allow running with `NODE\_PENDING\_DEPRECATION` (Anna Henningsen) [#18991](https://github.com/nodejs/node/pull/18991) +* [[`fd27165f73`](https://github.com/nodejs/node/commit/fd27165f73)] - **test**: specify 'dir' for directory symlinks (Kyle Farnung) [#19049](https://github.com/nodejs/node/pull/19049) +* [[`eca333a6e8`](https://github.com/nodejs/node/commit/eca333a6e8)] - **test**: refactor test after review (Andrew Johnston) [#18999](https://github.com/nodejs/node/pull/18999) +* [[`c943cd09a7`](https://github.com/nodejs/node/commit/c943cd09a7)] - **test**: fix repl-tab-complete --without-ssl (Daniel Bevenius) [#17867](https://github.com/nodejs/node/pull/17867) +* [[`f864509991`](https://github.com/nodejs/node/commit/f864509991)] - **test,benchmark**: use new Buffer API where appropriate (Сковорода Никита Андреевич) [#18980](https://github.com/nodejs/node/pull/18980) +* [[`479b622e49`](https://github.com/nodejs/node/commit/479b622e49)] - **tls,http2**: handle writes after SSL destroy more gracefully (Anna Henningsen) [#18987](https://github.com/nodejs/node/pull/18987) +* [[`3d4cda3a7d`](https://github.com/nodejs/node/commit/3d4cda3a7d)] - **(SEMVER-MINOR)** **trace_events**: add file pattern cli option (Andreas Madsen) [#18480](https://github.com/nodejs/node/pull/18480) +* [[`3e8e1524ac`](https://github.com/nodejs/node/commit/3e8e1524ac)] - **util**: use blue on non-windows systems for number (Gus Caplan) [#18925](https://github.com/nodejs/node/pull/18925) + ## 2018-03-02, Version 9.7.1 (Current), @rvagg diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md index fa2d1ae02d9..f07d20e0a86 100644 --- a/doc/onboarding-extras.md +++ b/doc/onboarding-extras.md @@ -52,17 +52,17 @@ If you cannot find who to cc for a file, `git shortlog -n -s ` may help. ### By Subsystem -We generally sort issues by a concept of "subsystem" so that we know what -part(s) of the codebase it touches. +Subsystems include: -**Subsystems generally are**: +* `lib/*.js` (`assert`, `buffer`, etc.) +* `build` +* `doc` +* `lib / src` +* `test` +* `tools` -* `lib/*.js` -* `doc`, `build`, `tools`, `test`, `deps`, `lib / src` (special), and there may - be others. -* `meta` for anything non-code (process) related - -There may be more than one subsystem valid for any particular issue / PR. +There may be more than one subsystem valid for any particular issue or pull +request. ### General @@ -72,6 +72,7 @@ Please use these when possible / appropriate * `discuss` - Things that need larger discussion * `feature request` - Any issue that requests a new feature (usually not PRs) * `good first issue` - Issues suitable for newcomers to process +* `meta` - For issues whose topic is governance, policies, procedures, etc. -- diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 4d5fc7d2ede..5a18e40b4f1 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -26,7 +26,6 @@ const util = require('util'); const EventEmitter = require('events'); const debug = util.debuglog('http'); const { async_id_symbol } = require('internal/async_hooks').symbols; -const { nextTick } = require('internal/process/next_tick'); // New Agent code. @@ -342,10 +341,7 @@ Agent.prototype.destroy = function destroy() { function handleSocketCreation(request, informRequest) { return function handleSocketCreation_Inner(err, socket) { if (err) { - const asyncId = (socket && socket._handle && socket._handle.getAsyncId) ? - socket._handle.getAsyncId() : - null; - nextTick(asyncId, () => request.emit('error', err)); + process.nextTick(emitErrorNT, request, err); return; } if (informRequest) @@ -355,6 +351,10 @@ function handleSocketCreation(request, informRequest) { }; } +function emitErrorNT(emitter, err) { + emitter.emit('error', err); +} + module.exports = { Agent, globalAgent: new Agent() diff --git a/lib/_http_client.js b/lib/_http_client.js index 3687288ee89..8e3d61a7561 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -36,9 +36,9 @@ const { const { OutgoingMessage } = require('_http_outgoing'); const Agent = require('_http_agent'); const { Buffer } = require('buffer'); +const { defaultTriggerAsyncIdScope } = require('internal/async_hooks'); const { urlToOptions, searchParamsSymbol } = require('internal/url'); const { outHeadersKey, ondrain } = require('internal/http'); -const { nextTick } = require('internal/process/next_tick'); const { ERR_HTTP_HEADERS_SENT, ERR_INVALID_ARG_TYPE, @@ -563,10 +563,10 @@ function responseKeepAlive(res, req) { socket.once('error', freeSocketErrorListener); // There are cases where _handle === null. Avoid those. Passing null to // nextTick() will call getDefaultTriggerAsyncId() to retrieve the id. - const asyncId = socket._handle ? socket._handle.getAsyncId() : null; + const asyncId = socket._handle ? socket._handle.getAsyncId() : undefined; // Mark this socket as available, AFTER user-added end // handlers have a chance to run. - nextTick(asyncId, emitFreeNT, socket); + defaultTriggerAsyncIdScope(asyncId, process.nextTick, emitFreeNT, socket); } } diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index cd7caae9ae7..1c2250a4b2d 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -31,8 +31,10 @@ const common = require('_http_common'); const checkIsHttpToken = common._checkIsHttpToken; const checkInvalidHeaderChar = common._checkInvalidHeaderChar; const { outHeadersKey } = require('internal/http'); -const { async_id_symbol } = require('internal/async_hooks').symbols; -const { nextTick } = require('internal/process/next_tick'); +const { + defaultTriggerAsyncIdScope, + symbols: { async_id_symbol } +} = require('internal/async_hooks'); const { ERR_HTTP_HEADERS_SENT, ERR_HTTP_INVALID_HEADER_VALUE, @@ -272,15 +274,14 @@ function _writeRaw(data, encoding, callback) { this._flushOutput(conn); } else if (!data.length) { if (typeof callback === 'function') { - let socketAsyncId = this.socket[async_id_symbol]; // If the socket was set directly it won't be correctly initialized // with an async_id_symbol. // TODO(AndreasMadsen): @trevnorris suggested some more correct // solutions in: // https://github.com/nodejs/node/pull/14389/files#r128522202 - if (socketAsyncId === undefined) socketAsyncId = null; - - nextTick(socketAsyncId, callback); + defaultTriggerAsyncIdScope(conn[async_id_symbol], + process.nextTick, + callback); } return true; } @@ -633,10 +634,13 @@ OutgoingMessage.prototype.write = function write(chunk, encoding, callback) { function write_(msg, chunk, encoding, callback, fromEnd) { if (msg.finished) { const err = new ERR_STREAM_WRITE_AFTER_END(); - nextTick(msg.socket && msg.socket[async_id_symbol], - writeAfterEndNT.bind(msg), - err, - callback); + const triggerAsyncId = msg.socket ? msg.socket[async_id_symbol] : undefined; + defaultTriggerAsyncIdScope(triggerAsyncId, + process.nextTick, + writeAfterEndNT, + msg, + err, + callback); return true; } @@ -686,8 +690,8 @@ function write_(msg, chunk, encoding, callback, fromEnd) { } -function writeAfterEndNT(err, callback) { - this.emit('error', err); +function writeAfterEndNT(msg, err, callback) { + msg.emit('error', err); if (callback) callback(err); } diff --git a/lib/dgram.js b/lib/dgram.js index 78730635cbe..b9caeddabe2 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -44,7 +44,6 @@ const { symbols: { async_id_symbol } } = require('internal/async_hooks'); const { UV_UDP_REUSEADDR } = process.binding('constants').os; -const { nextTick } = require('internal/process/next_tick'); const { UDP, SendWrap } = process.binding('udp_wrap'); @@ -526,7 +525,10 @@ Socket.prototype.close = function(callback) { this._stopReceiving(); this._handle.close(); this._handle = null; - nextTick(this[async_id_symbol], socketCloseNT, this); + defaultTriggerAsyncIdScope(this[async_id_symbol], + process.nextTick, + socketCloseNT, + this); return this; }; diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 72d74243d8c..8c4fd08fd83 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -281,6 +281,8 @@ function clearDefaultTriggerAsyncId() { function defaultTriggerAsyncIdScope(triggerAsyncId, block, ...args) { + if (triggerAsyncId === undefined) + return Reflect.apply(block, null, args); // CHECK(Number.isSafeInteger(triggerAsyncId)) // CHECK(triggerAsyncId > 0) const oldDefaultTriggerAsyncId = async_id_fields[kDefaultTriggerAsyncId]; diff --git a/lib/internal/loader/DefaultResolve.js b/lib/internal/loader/DefaultResolve.js index c561417bd16..f99e0c98b92 100644 --- a/lib/internal/loader/DefaultResolve.js +++ b/lib/internal/loader/DefaultResolve.js @@ -43,7 +43,7 @@ function search(target, base) { } const extensionFormatMap = { - __proto__: null, + '__proto__': null, '.mjs': 'esm', '.json': 'json', '.node': 'addon', diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js index 39e5a6f8124..7acf266cb7f 100644 --- a/lib/internal/process/next_tick.js +++ b/lib/internal/process/next_tick.js @@ -1,8 +1,6 @@ 'use strict'; exports.setup = setupNextTick; -// Will be overwritten when setupNextTick() is called. -exports.nextTick = null; function setupNextTick() { const { @@ -87,9 +85,6 @@ function setupNextTick() { // Needs to be accessible from beyond this scope. process._tickCallback = _tickCallback; - // Set the nextTick() function for internal usage. - exports.nextTick = internalNextTick; - function _tickCallback() { let tock; do { @@ -165,32 +160,4 @@ function setupNextTick() { push(new TickObject(callback, args, getDefaultTriggerAsyncId())); } - - // `internalNextTick()` will not enqueue any callback when the process is - // about to exit since the callback would not have a chance to be executed. - function internalNextTick(triggerAsyncId, callback) { - if (typeof callback !== 'function') - throw new ERR_INVALID_CALLBACK(); - // CHECK(Number.isSafeInteger(triggerAsyncId) || triggerAsyncId === null) - // CHECK(triggerAsyncId > 0 || triggerAsyncId === null) - - if (process._exiting) - return; - - var args; - switch (arguments.length) { - case 2: break; - case 3: args = [arguments[2]]; break; - case 4: args = [arguments[2], arguments[3]]; break; - case 5: args = [arguments[2], arguments[3], arguments[4]]; break; - default: - args = new Array(arguments.length - 2); - for (var i = 2; i < arguments.length; i++) - args[i - 2] = arguments[i]; - } - - if (triggerAsyncId === null) - triggerAsyncId = getDefaultTriggerAsyncId(); - push(new TickObject(callback, args, triggerAsyncId)); - } } diff --git a/lib/net.js b/lib/net.js index 7fa1e20aeda..19f5b135891 100644 --- a/lib/net.js +++ b/lib/net.js @@ -52,7 +52,6 @@ const { defaultTriggerAsyncIdScope, symbols: { async_id_symbol } } = require('internal/async_hooks'); -const { nextTick } = require('internal/process/next_tick'); const errors = require('internal/errors'); const { ERR_INVALID_ARG_TYPE, @@ -392,7 +391,7 @@ function writeAfterFIN(chunk, encoding, cb) { // TODO: defer error events consistently everywhere, not just the cb this.emit('error', er); if (typeof cb === 'function') { - nextTick(this[async_id_symbol], cb, er); + defaultTriggerAsyncIdScope(this[async_id_symbol], process.nextTick, cb, er); } } @@ -1069,7 +1068,7 @@ function lookupAndConnect(self, options) { // If host is an IP, skip performing a lookup var addressType = isIP(host); if (addressType) { - nextTick(self[async_id_symbol], function() { + defaultTriggerAsyncIdScope(self[async_id_symbol], process.nextTick, () => { if (self.connecting) defaultTriggerAsyncIdScope( self[async_id_symbol], @@ -1372,7 +1371,11 @@ function setupListenHandle(address, port, addressType, backlog, fd) { var ex = exceptionWithHostPort(err, 'listen', address, port); this._handle.close(); this._handle = null; - nextTick(this[async_id_symbol], emitErrorNT, this, ex); + defaultTriggerAsyncIdScope(this[async_id_symbol], + process.nextTick, + emitErrorNT, + this, + ex); return; } @@ -1383,7 +1386,10 @@ function setupListenHandle(address, port, addressType, backlog, fd) { if (this._unref) this.unref(); - nextTick(this[async_id_symbol], emitListeningNT, this); + defaultTriggerAsyncIdScope(this[async_id_symbol], + process.nextTick, + emitListeningNT, + this); } Server.prototype._listen2 = setupListenHandle; // legacy alias @@ -1590,8 +1596,11 @@ Server.prototype.getConnections = function(cb) { const self = this; function end(err, connections) { - const asyncId = self._handle ? self[async_id_symbol] : null; - nextTick(asyncId, cb, err, connections); + defaultTriggerAsyncIdScope(self[async_id_symbol], + process.nextTick, + cb, + err, + connections); } if (!this._usingWorkers) { @@ -1669,8 +1678,10 @@ Server.prototype._emitCloseIfDrained = function() { return; } - const asyncId = this._handle ? this[async_id_symbol] : null; - nextTick(asyncId, emitCloseNT, this); + defaultTriggerAsyncIdScope(this[async_id_symbol], + process.nextTick, + emitCloseNT, + this); }; diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 08bb73f7468..e2656e4eec3 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -415,14 +415,14 @@ void AsyncWrap::WeakCallback(const v8::WeakCallbackInfo& info) { HandleScope scope(info.GetIsolate()); Environment* env = Environment::GetCurrent(info.GetIsolate()); - DestroyParam* p = info.GetParameter(); + std::unique_ptr p{info.GetParameter()}; Local prop_bag = PersistentToLocal(info.GetIsolate(), p->propBag); Local val = prop_bag->Get(env->destroyed_string()); if (val->IsFalse()) { AsyncWrap::EmitDestroy(env, p->asyncId); } - delete p; + // unique_ptr goes out of scope here and pointer is deleted. } diff --git a/src/env-inl.h b/src/env-inl.h index 365ace55784..a91ef578c8a 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -31,6 +31,7 @@ #include "uv.h" #include "v8.h" #include "node_perf_common.h" +#include "node_context_data.h" #include #include @@ -283,7 +284,8 @@ inline void Environment::TickInfo::set_has_thrown(bool state) { inline void Environment::AssignToContext(v8::Local context, const ContextInfo& info) { - context->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, this); + context->SetAlignedPointerInEmbedderData( + ContextEmbedderIndex::kEnvironment, this); #if HAVE_INSPECTOR inspector_agent()->ContextCreated(context, info); #endif // HAVE_INSPECTOR @@ -295,7 +297,8 @@ inline Environment* Environment::GetCurrent(v8::Isolate* isolate) { inline Environment* Environment::GetCurrent(v8::Local context) { return static_cast( - context->GetAlignedPointerFromEmbedderData(kContextEmbedderDataIndex)); + context->GetAlignedPointerFromEmbedderData( + ContextEmbedderIndex::kEnvironment)); } inline Environment* Environment::GetCurrent( @@ -327,6 +330,7 @@ inline Environment::Environment(IsolateData* isolate_data, trace_sync_io_(false), abort_on_uncaught_exception_(false), emit_napi_warning_(true), + emit_env_nonstring_warning_(true), makecallback_cntr_(0), should_abort_on_uncaught_toggle_(isolate_, 1), #if HAVE_INSPECTOR @@ -368,8 +372,8 @@ inline Environment::~Environment() { inspector_agent_.reset(); #endif - context()->SetAlignedPointerInEmbedderData(kContextEmbedderDataIndex, - nullptr); + context()->SetAlignedPointerInEmbedderData( + ContextEmbedderIndex::kEnvironment, nullptr); delete[] heap_statistics_buffer_; delete[] heap_space_statistics_buffer_; diff --git a/src/env.h b/src/env.h index 4df4cb13b82..8c73b8b206e 100644 --- a/src/env.h +++ b/src/env.h @@ -75,14 +75,6 @@ struct PackageConfig { }; } // namespace loader -// Pick an index that's hopefully out of the way when we're embedded inside -// another application. Performance-wise or memory-wise it doesn't matter: -// Context::SetAlignedPointerInEmbedderData() is backed by a FixedArray, -// worst case we pay a one-time penalty for resizing the array. -#ifndef NODE_CONTEXT_EMBEDDER_DATA_INDEX -#define NODE_CONTEXT_EMBEDDER_DATA_INDEX 32 -#endif - // The number of items passed to push_values_to_array_function has diminishing // returns around 8. This should be used at all call sites using said function. #ifndef NODE_PUSH_VAL_TO_ARRAY_MAX @@ -730,11 +722,14 @@ class Environment { inline HandleWrapQueue* handle_wrap_queue() { return &handle_wrap_queue_; } inline ReqWrapQueue* req_wrap_queue() { return &req_wrap_queue_; } - static const int kContextEmbedderDataIndex = NODE_CONTEXT_EMBEDDER_DATA_INDEX; - void AddPromiseHook(promise_hook_func fn, void* arg); bool RemovePromiseHook(promise_hook_func fn, void* arg); bool EmitNapiWarning(); + inline bool EmitProcessEnvWarning() { + bool current_value = emit_env_nonstring_warning_; + emit_env_nonstring_warning_ = false; + return current_value; + } typedef void (*native_immediate_callback)(Environment* env, void* data); // cb will be called as cb(env, data) on the next event loop iteration. @@ -789,6 +784,7 @@ class Environment { bool trace_sync_io_; bool abort_on_uncaught_exception_; bool emit_napi_warning_; + bool emit_env_nonstring_warning_; size_t makecallback_cntr_; std::vector destroy_async_id_list_; diff --git a/src/node.cc b/src/node.cc index 15251a848af..df4c9cd0f09 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2696,6 +2696,17 @@ static void EnvGetter(Local property, static void EnvSetter(Local property, Local value, const PropertyCallbackInfo& info) { + Environment* env = Environment::GetCurrent(info); + if (config_pending_deprecation && env->EmitProcessEnvWarning() && + !value->IsString() && !value->IsNumber() && !value->IsBoolean()) { + if (ProcessEmitDeprecationWarning( + env, + "Assigning any value other than a string, number, or boolean to a " + "process.env property is deprecated. Please make sure to convert the " + "value to a string before setting process.env with it.", + "DEP0104").IsNothing()) + return; + } #ifdef __POSIX__ node::Utf8Value key(info.GetIsolate(), property); node::Utf8Value val(info.GetIsolate(), value); diff --git a/src/node_context_data.h b/src/node_context_data.h new file mode 100644 index 00000000000..9d3145bb800 --- /dev/null +++ b/src/node_context_data.h @@ -0,0 +1,25 @@ +#ifndef SRC_NODE_CONTEXT_DATA_H_ +#define SRC_NODE_CONTEXT_DATA_H_ + +namespace node { + +// Pick an index that's hopefully out of the way when we're embedded inside +// another application. Performance-wise or memory-wise it doesn't matter: +// Context::SetAlignedPointerInEmbedderData() is backed by a FixedArray, +// worst case we pay a one-time penalty for resizing the array. +#ifndef NODE_CONTEXT_EMBEDDER_DATA_INDEX +#define NODE_CONTEXT_EMBEDDER_DATA_INDEX 32 +#endif + +#ifndef NODE_CONTEXT_SANDBOX_OBJECT_INDEX +#define NODE_CONTEXT_SANDBOX_OBJECT_INDEX 33 +#endif + +enum ContextEmbedderIndex { + kEnvironment = NODE_CONTEXT_EMBEDDER_DATA_INDEX, + kSandboxObject = NODE_CONTEXT_SANDBOX_OBJECT_INDEX, +}; + +} // namespace node + +#endif // SRC_NODE_CONTEXT_DATA_H_ diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 4c8a96537f8..de910758437 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -23,6 +23,7 @@ #include "node_watchdog.h" #include "base_object-inl.h" #include "node_contextify.h" +#include "node_context_data.h" namespace node { namespace contextify { @@ -178,7 +179,7 @@ Local ContextifyContext::CreateV8Context( // embedder data field. However, we cannot hold a reference to a v8::Context // directly in an Object, we instead hold onto the new context's global // object instead (which then has a reference to the context). - ctx->SetEmbedderData(kSandboxObjectIndex, sandbox_obj); + ctx->SetEmbedderData(ContextEmbedderIndex::kSandboxObject, sandbox_obj); sandbox_obj->SetPrivate(env->context(), env->contextify_global_private_symbol(), ctx->Global()); diff --git a/src/node_contextify.h b/src/node_contextify.h index 9f83740e43c..b25e1a75d4f 100644 --- a/src/node_contextify.h +++ b/src/node_contextify.h @@ -4,16 +4,13 @@ #include "node_internals.h" #include "node_watchdog.h" #include "base_object-inl.h" +#include "node_context_data.h" namespace node { namespace contextify { class ContextifyContext { protected: - // V8 reserves the first field in context objects for the debugger. We use the - // second field to hold a reference to the sandbox object. - enum { kSandboxObjectIndex = 1 }; - Environment* const env_; Persistent context_; @@ -45,7 +42,7 @@ class ContextifyContext { inline v8::Local sandbox() const { return v8::Local::Cast( - context()->GetEmbedderData(kSandboxObjectIndex)); + context()->GetEmbedderData(ContextEmbedderIndex::kSandboxObject)); } private: diff --git a/src/node_postmortem_metadata.cc b/src/node_postmortem_metadata.cc index b335e7fbf81..93bf5a4dd7d 100644 --- a/src/node_postmortem_metadata.cc +++ b/src/node_postmortem_metadata.cc @@ -4,6 +4,7 @@ #include "util-inl.h" #include "req_wrap.h" #include "v8abbr.h" +#include "node_context_data.h" #define NODEDBG_SYMBOL(Name) nodedbg_ ## Name @@ -34,7 +35,7 @@ V(ListNode_ReqWrap, next_, uintptr_t, ListNode>::next_) extern "C" { -int nodedbg_const_Environment__kContextEmbedderDataIndex__int; +int nodedbg_const_ContextEmbedderIndex__kEnvironment__int; uintptr_t nodedbg_offset_ExternalString__data__uintptr_t; #define V(Class, Member, Type, Accessor) \ @@ -46,8 +47,8 @@ uintptr_t nodedbg_offset_ExternalString__data__uintptr_t; namespace node { int GenDebugSymbols() { - nodedbg_const_Environment__kContextEmbedderDataIndex__int = - Environment::kContextEmbedderDataIndex; + nodedbg_const_ContextEmbedderIndex__kEnvironment__int = + ContextEmbedderIndex::kEnvironment; nodedbg_offset_ExternalString__data__uintptr_t = NODE_OFF_EXTSTR_DATA; diff --git a/test/async-hooks/test-internal-nexttick-default-trigger.js b/test/async-hooks/test-internal-nexttick-default-trigger.js deleted file mode 100644 index ed541868542..00000000000 --- a/test/async-hooks/test-internal-nexttick-default-trigger.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -// Flags: --expose-internals -const common = require('../common'); - -// This tests ensures that the triggerId of both the internal and external -// nextTick function sets the triggerAsyncId correctly. - -const assert = require('assert'); -const async_hooks = require('async_hooks'); -const initHooks = require('./init-hooks'); -const { checkInvocations } = require('./hook-checks'); -const internal = require('internal/process/next_tick'); - -const hooks = initHooks(); -hooks.enable(); - -const rootAsyncId = async_hooks.executionAsyncId(); - -// public -process.nextTick(common.mustCall(function() { - assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId); -})); - -// internal default -internal.nextTick(null, common.mustCall(function() { - assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId); -})); - -// internal -internal.nextTick(rootAsyncId + 1, common.mustCall(function() { - assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId + 1); -})); - -process.on('exit', function() { - hooks.sanityCheck(); - - const as = hooks.activitiesOfTypes('TickObject'); - checkInvocations(as[0], { - init: 1, before: 1, after: 1, destroy: 1 - }, 'when process exits'); - checkInvocations(as[1], { - init: 1, before: 1, after: 1, destroy: 1 - }, 'when process exits'); - checkInvocations(as[2], { - init: 1, before: 1, after: 1, destroy: 1 - }, 'when process exits'); -}); diff --git a/test/async-hooks/test-nexttick-default-trigger.js b/test/async-hooks/test-nexttick-default-trigger.js new file mode 100644 index 00000000000..1bc93f29737 --- /dev/null +++ b/test/async-hooks/test-nexttick-default-trigger.js @@ -0,0 +1,28 @@ +'use strict'; +const common = require('../common'); + +// This tests ensures that the triggerId of the nextTick function sets the +// triggerAsyncId correctly. + +const assert = require('assert'); +const async_hooks = require('async_hooks'); +const initHooks = require('./init-hooks'); +const { checkInvocations } = require('./hook-checks'); + +const hooks = initHooks(); +hooks.enable(); + +const rootAsyncId = async_hooks.executionAsyncId(); + +process.nextTick(common.mustCall(function() { + assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId); +})); + +process.on('exit', function() { + hooks.sanityCheck(); + + const as = hooks.activitiesOfTypes('TickObject'); + checkInvocations(as[0], { + init: 1, before: 1, after: 1, destroy: 1 + }, 'when process exits'); +}); diff --git a/test/async-hooks/test-no-assert-when-disabled.js b/test/async-hooks/test-no-assert-when-disabled.js index 1d26897ab05..12742bd5d4f 100644 --- a/test/async-hooks/test-no-assert-when-disabled.js +++ b/test/async-hooks/test-no-assert-when-disabled.js @@ -1,15 +1,8 @@ 'use strict'; // Flags: --no-force-async-hooks-checks --expose-internals -const common = require('../common'); +require('../common'); const async_hooks = require('internal/async_hooks'); -const internal = require('internal/process/next_tick'); - -// Using undefined as the triggerAsyncId. -// Ref: https://github.com/nodejs/node/issues/14386 -// Ref: https://github.com/nodejs/node/issues/14381 -// Ref: https://github.com/nodejs/node/issues/14368 -internal.nextTick(undefined, common.mustCall()); // Negative asyncIds and invalid type name async_hooks.emitInit(-1, null, -1, {}); diff --git a/test/cctest/test_node_postmortem_metadata.cc b/test/cctest/test_node_postmortem_metadata.cc index e901d97668f..335f3e85812 100644 --- a/test/cctest/test_node_postmortem_metadata.cc +++ b/test/cctest/test_node_postmortem_metadata.cc @@ -13,7 +13,7 @@ extern uintptr_t extern uintptr_t nodedbg_offset_Environment__handle_wrap_queue___Environment_HandleWrapQueue; extern int debug_symbols_generated; -extern int nodedbg_const_Environment__kContextEmbedderDataIndex__int; +extern int nodedbg_const_ContextEmbedderIndex__kEnvironment__int; extern uintptr_t nodedbg_offset_Environment_HandleWrapQueue__head___ListNode_HandleWrap; extern uintptr_t @@ -56,10 +56,10 @@ class TestReqWrap : public node::ReqWrap { node::AsyncWrap::PROVIDER_TIMERWRAP) {} }; -TEST_F(DebugSymbolsTest, ContextEmbedderDataIndex) { - int kContextEmbedderDataIndex = node::Environment::kContextEmbedderDataIndex; - EXPECT_EQ(nodedbg_const_Environment__kContextEmbedderDataIndex__int, - kContextEmbedderDataIndex); +TEST_F(DebugSymbolsTest, ContextEmbedderEnvironmentIndex) { + int kEnvironmentIndex = node::ContextEmbedderIndex::kEnvironment; + EXPECT_EQ(nodedbg_const_ContextEmbedderIndex__kEnvironment__int, + kEnvironmentIndex); } TEST_F(DebugSymbolsTest, ExternalStringDataOffset) { diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index 1be086c3a6a..993050924a3 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -102,9 +102,9 @@ const testData = [ meta: { added: ['v5.3.0', 'v4.2.0'], changes: [ - { version: 'v4.2.0', + { 'version': 'v4.2.0', 'pr-url': 'https://github.com/nodejs/node/pull/3276', - description: 'The `error` parameter can now be ' + + 'description': 'The `error` parameter can now be ' + 'an arrow function.' } ] diff --git a/test/fixtures/test-regress-GH-4015.js b/test/fixtures/test-fs-stat-sync-overflow.js similarity index 100% rename from test/fixtures/test-regress-GH-4015.js rename to test/fixtures/test-fs-stat-sync-overflow.js diff --git a/test/parallel/test-http-client-headers-array.js b/test/parallel/test-http-client-headers-array.js index dffe04bb108..c637de61c01 100644 --- a/test/parallel/test-http-client-headers-array.js +++ b/test/parallel/test-http-client-headers-array.js @@ -9,8 +9,8 @@ function execute(options) { http.createServer(function(req, res) { const expectHeaders = { 'x-foo': 'boom', - cookie: 'a=1; b=2; c=3', - connection: 'close' + 'cookie': 'a=1; b=2; c=3', + 'connection': 'close' }; // no Host header when you set headers an array diff --git a/test/parallel/test-http-raw-headers.js b/test/parallel/test-http-raw-headers.js index eb3f7280f89..8ce20db3513 100644 --- a/test/parallel/test-http-raw-headers.js +++ b/test/parallel/test-http-raw-headers.js @@ -37,10 +37,10 @@ http.createServer(function(req, res) { 'close' ]; const expectHeaders = { - host: `localhost:${this.address().port}`, + 'host': `localhost:${this.address().port}`, 'transfer-encoding': 'CHUNKED', 'x-bar': 'yoyoyo', - connection: 'close' + 'connection': 'close' }; const expectRawTrailers = [ 'x-bAr', @@ -96,9 +96,9 @@ http.createServer(function(req, res) { 'chunked' ]; const expectHeaders = { - trailer: 'x-foo', - date: null, - connection: 'close', + 'trailer': 'x-foo', + 'date': null, + 'connection': 'close', 'transfer-encoding': 'chunked' }; res.rawHeaders[3] = null; diff --git a/test/parallel/test-http2-compat-expect-continue-check.js b/test/parallel/test-http2-compat-expect-continue-check.js index 6aded8b5293..4f2514a44a4 100644 --- a/test/parallel/test-http2-compat-expect-continue-check.js +++ b/test/parallel/test-http2-compat-expect-continue-check.js @@ -33,7 +33,7 @@ server.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request({ ':method': 'POST', - expect: '100-continue' + 'expect': '100-continue' }); let gotContinue = false; diff --git a/test/parallel/test-http2-compat-expect-continue.js b/test/parallel/test-http2-compat-expect-continue.js index 42fa80ae4e8..cb90e51f3bc 100644 --- a/test/parallel/test-http2-compat-expect-continue.js +++ b/test/parallel/test-http2-compat-expect-continue.js @@ -29,7 +29,7 @@ server.on('listening', common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request({ ':method': 'POST', - expect: '100-continue' + 'expect': '100-continue' }); let gotContinue = false; diff --git a/test/parallel/test-http2-compat-expect-handling.js b/test/parallel/test-http2-compat-expect-handling.js index e9871184763..77f22758345 100644 --- a/test/parallel/test-http2-compat-expect-handling.js +++ b/test/parallel/test-http2-compat-expect-handling.js @@ -30,7 +30,7 @@ function nextTest(testsToRun) { ':method': 'GET', ':scheme': 'http', ':authority': `localhost:${port}`, - expect: expectValue + 'expect': expectValue }); req.on('response', common.mustCall((headers) => { diff --git a/test/parallel/test-http2-cookies.js b/test/parallel/test-http2-cookies.js index cf763915389..8b371d8c426 100644 --- a/test/parallel/test-http2-cookies.js +++ b/test/parallel/test-http2-cookies.js @@ -41,8 +41,8 @@ server.on('listening', common.mustCall(() => { const req = client.request({ ':path': '/', - abc: [1, 2, 3], - cookie: ['a=b', 'c=d', 'e=f'], + 'abc': [1, 2, 3], + 'cookie': ['a=b', 'c=d', 'e=f'], }); req.resume(); diff --git a/test/parallel/test-http2-server-rst-before-respond.js b/test/parallel/test-http2-server-rst-before-respond.js index 74181f4ffa0..c2831d33079 100644 --- a/test/parallel/test-http2-server-rst-before-respond.js +++ b/test/parallel/test-http2-server-rst-before-respond.js @@ -17,7 +17,7 @@ function onStream(stream, headers, flags) { common.expectsError(() => { stream.additionalHeaders({ ':status': 123, - abc: 123 + 'abc': 123 }); }, { code: 'ERR_HTTP2_INVALID_STREAM' }); } diff --git a/test/parallel/test-http2-server-rst-stream.js b/test/parallel/test-http2-server-rst-stream.js index 4a58091aa61..d19704509a5 100644 --- a/test/parallel/test-http2-server-rst-stream.js +++ b/test/parallel/test-http2-server-rst-stream.js @@ -40,7 +40,7 @@ server.listen(0, common.mustCall(() => { tests.forEach((test) => { const req = client.request({ ':method': 'POST', - rstcode: test[0] + 'rstcode': test[0] }); req.on('close', common.mustCall((code) => { assert.strictEqual(code, test[0]); diff --git a/test/parallel/test-process-env-deprecation.js b/test/parallel/test-process-env-deprecation.js new file mode 100644 index 00000000000..68817b320b4 --- /dev/null +++ b/test/parallel/test-process-env-deprecation.js @@ -0,0 +1,16 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); + +// Flags: --pending-deprecation + +common.expectWarning( + 'DeprecationWarning', + 'Assigning any value other than a string, number, or boolean to a ' + + 'process.env property is deprecated. Please make sure to convert the value ' + + 'to a string before setting process.env with it.', + 'DEP0104' +); + +process.env.ABC = undefined; +assert.strictEqual(process.env.ABC, 'undefined'); diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index f4046c33a11..7b77a42a167 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -75,8 +75,8 @@ const qsTestCases = [ ['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }], ['a=b&c&d=e', 'a=b&c=&d=e', { a: 'b', c: '', d: 'e' }], ['a=b&c=&d=e', 'a=b&c=&d=e', { a: 'b', c: '', d: 'e' }], - ['a=b&=c&d=e', 'a=b&=c&d=e', { a: 'b', '': 'c', d: 'e' }], - ['a=b&=&c=d', 'a=b&=&c=d', { a: 'b', '': '', c: 'd' }], + ['a=b&=c&d=e', 'a=b&=c&d=e', { 'a': 'b', '': 'c', 'd': 'e' }], + ['a=b&=&c=d', 'a=b&=&c=d', { 'a': 'b', '': '', 'c': 'd' }], ['&&foo=bar&&', 'foo=bar', { foo: 'bar' }], ['&', '', {}], ['&&&&', '', {}], diff --git a/test/parallel/test-vm-module-link.js b/test/parallel/test-vm-module-link.js index 843c1fdc517..d9ee8e7767f 100644 --- a/test/parallel/test-vm-module-link.js +++ b/test/parallel/test-vm-module-link.js @@ -88,7 +88,7 @@ async function circular() { async function circular2() { const sourceMap = { - root: ` + 'root': ` import * as a from './a.mjs'; import * as b from './b.mjs'; if (!('fromA' in a)) diff --git a/test/sequential/test-regress-GH-1726.js b/test/sequential/test-child-process-exit.js similarity index 98% rename from test/sequential/test-regress-GH-1726.js rename to test/sequential/test-child-process-exit.js index 1291dec261c..303f015cf0a 100644 --- a/test/sequential/test-regress-GH-1726.js +++ b/test/sequential/test-child-process-exit.js @@ -20,12 +20,13 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; +require('../common'); + // Open a chain of five Node processes each a child of the next. The final -// process exits immediately. Each process in the chain is instructed to -// exit when its child exits. +// process exits immediately. Each process in the chain is instructed to exit +// when its child exits. // https://github.com/joyent/node/issues/1726 -require('../common'); const assert = require('assert'); const ch = require('child_process'); diff --git a/test/sequential/test-regress-GH-4015.js b/test/sequential/test-fs-stat-sync-overflow.js similarity index 71% rename from test/sequential/test-regress-GH-4015.js rename to test/sequential/test-fs-stat-sync-overflow.js index bdb7a8b1e2d..9c9109989a1 100644 --- a/test/sequential/test-regress-GH-4015.js +++ b/test/sequential/test-fs-stat-sync-overflow.js @@ -20,18 +20,22 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const { fixturesDir } = require('../common/fixtures'); + +// Check that the calls to Integer::New() and Date::New() succeed and bail out +// if they don't. +// V8 returns an empty handle on stack overflow. Trying to set the empty handle +// as a property on an object results in a NULL pointer dereference in release +// builds and an assert in debug builds. +// https://github.com/nodejs/node-v0.x-archive/issues/4015 + const assert = require('assert'); const { exec } = require('child_process'); const cmd = - `"${process.execPath}" "${fixturesDir}/test-regress-GH-4015.js"`; + `"${process.execPath}" "${fixturesDir}/test-fs-stat-sync-overflow.js"`; exec(cmd, function(err, stdout, stderr) { - const expectedError = common.engineSpecificMessage({ - v8: /RangeError: Maximum call stack size exceeded/, - chakracore: /Error: Out of stack space/ - }); - assert(expectedError.test(stderr)); + assert(/RangeError: Maximum call stack size exceeded/.test(stderr)); }); diff --git a/test/sequential/test-regress-GH-4027.js b/test/sequential/test-fs-watch-file-enoent-after-deletion.js similarity index 81% rename from test/sequential/test-regress-GH-4027.js rename to test/sequential/test-fs-watch-file-enoent-after-deletion.js index 89365373235..f5b9012acab 100644 --- a/test/sequential/test-regress-GH-4027.js +++ b/test/sequential/test-fs-watch-file-enoent-after-deletion.js @@ -21,6 +21,17 @@ 'use strict'; const common = require('../common'); + +// Make sure the deletion event gets reported in the following scenario: +// 1. Watch a file. +// 2. The initial stat() goes okay. +// 3. Something deletes the watched file. +// 4. The second stat() fails with ENOENT. + +// The second stat() translates into the first 'change' event but a logic error +// stopped it from getting emitted. +// https://github.com/nodejs/node-v0.x-archive/issues/4027 + const assert = require('assert'); const path = require('path'); const fs = require('fs'); diff --git a/test/sequential/test-regress-GH-784.js b/test/sequential/test-http-econnrefused.js similarity index 96% rename from test/sequential/test-regress-GH-784.js rename to test/sequential/test-http-econnrefused.js index 4b285020d45..ff4508963b9 100644 --- a/test/sequential/test-regress-GH-784.js +++ b/test/sequential/test-http-econnrefused.js @@ -20,15 +20,15 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -// Regression test for GH-784 -// https://github.com/joyent/node/issues/784 -// +const common = require('../common'); + // The test works by making a total of 8 requests to the server. The first // two are made with the server off - they should come back as ECONNREFUSED. // The next two are made with server on - they should come back successful. // The next two are made with the server off - and so on. Without the fix -// we were experiencing parse errors and instead of ECONNREFUSED. -const common = require('../common'); +// we were experiencing parse errors instead of ECONNREFUSED. +// https://github.com/nodejs/node-v0.x-archive/issues/784 + const http = require('http'); const assert = require('assert'); diff --git a/test/sequential/test-regress-GH-877.js b/test/sequential/test-http-max-sockets.js similarity index 94% rename from test/sequential/test-regress-GH-877.js rename to test/sequential/test-http-max-sockets.js index c717c2dd74f..24629448f7a 100644 --- a/test/sequential/test-regress-GH-877.js +++ b/test/sequential/test-http-max-sockets.js @@ -21,6 +21,10 @@ 'use strict'; const common = require('../common'); + +// Make sure http server doesn't wait for socket pool to establish connections +// https://github.com/nodejs/node-v0.x-archive/issues/877 + const http = require('http'); const assert = require('assert'); diff --git a/test/sequential/test-regress-GH-1697.js b/test/sequential/test-net-response-size.js similarity index 91% rename from test/sequential/test-regress-GH-1697.js rename to test/sequential/test-net-response-size.js index 9d2555705ab..c5d7e9b600e 100644 --- a/test/sequential/test-regress-GH-1697.js +++ b/test/sequential/test-net-response-size.js @@ -21,6 +21,11 @@ 'use strict'; const common = require('../common'); + +// Make sure the net module's server doesn't throw an error when handling +// responses that are either too long or too small (especially on Windows) +// https://github.com/nodejs/node-v0.x-archive/issues/1697 + const net = require('net'); const cp = require('child_process'); diff --git a/tools/eslint-rules/no-unescaped-regexp-dot.js b/tools/eslint-rules/no-unescaped-regexp-dot.js index d0c57507129..3af514d4bb9 100644 --- a/tools/eslint-rules/no-unescaped-regexp-dot.js +++ b/tools/eslint-rules/no-unescaped-regexp-dot.js @@ -120,10 +120,10 @@ module.exports = function(context) { } return { - TemplateLiteral: checkLiteral, - Literal: checkLiteral, - CallExpression: checkRegExpStart, - NewExpression: checkRegExpStart, + 'TemplateLiteral': checkLiteral, + 'Literal': checkLiteral, + 'CallExpression': checkRegExpStart, + 'NewExpression': checkRegExpStart, 'CallExpression:exit': checkRegExpEnd, 'NewExpression:exit': checkRegExpEnd };