Commit Graph

254 Commits

Author SHA1 Message Date
Antoine du Hamel
47ad609d64
test: fix addons and node-api test assumptions
PR-URL: https://github.com/nodejs/node/pull/55441
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2024-10-22 07:49:19 +00:00
Nathan Baulch
28c7394319
test: fix typos
PR-URL: https://github.com/nodejs/node/pull/55063
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2024-09-28 13:58:55 +00:00
tannal
0b6b2a4dc7
test: merge ongc and gcutil into gc.js
PR-URL: https://github.com/nodejs/node/pull/54355
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
2024-08-29 08:49:52 +01:00
Joyee Cheung
0be79f4deb
src: remove dependency on wrapper-descriptor-based CppHeap
As V8 has moved away from wrapper-descriptor-based CppHeap, this
patch:

1. Create the CppHeap without using wrapper descirptors.
2. Deprecates node::SetCppgcReference() in favor of
   v8::Object::Wrap() since the wrapper descriptor is no longer
   relevant. It is still kept as a compatibility layer for addons
   that need to also work on Node.js versions without
   v8::Object::Wrap().

PR-URL: https://github.com/nodejs/node/pull/54077
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-08-16 16:04:35 +02:00
Richard Lau
43ab5b9596
test: fix test when compiled without engine support
Update the `addons/openssl-test-engine` test to pass when OpenSSL
has been compiled without support for custom engines. OpenSSL 3
deprecated support for engines, with the recommendation to move
to the provider model.

PR-URL: https://github.com/nodejs/node/pull/53232
Refs: https://github.com/openssl/openssl/blob/openssl-3.0.0/README-ENGINES.md
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-06-02 18:12:23 +00:00
Chengzhong Wu
8b2011a818
build: define NOMINMAX in common.gypi
V8 and Node.js had defined `NOMINMAX` on Windows for a long time.  In
recent changes, V8 added `std::numeric_limits::min` usages in its
header files which caused addons without `NOMINMAX` defines failed
to compile.

Define `NOMINMAX` in common.gypi so that addons can be compiled with
the latest V8 header files.

PR-URL: https://github.com/nodejs/node/pull/52794
Fixes: https://github.com/nodejs/nan/issues/968
Refs: https://github.com/nodejs/gyp-next/pull/244
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2024-05-04 13:55:06 +00:00
Michaël Zasso
d9c47e9b5f
src: add missing TryCatch
Otherwise re-entering V8 doesn't work as expected after exceptions
were thrown.

Refs: https://chromium-review.googlesource.com/c/v8/v8/+/5050065

Co-Authored-By: Toon Verwaest <verwaest@chromium.org>
Co-Authored-By: deepak1556 <hop2deep@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/51362
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2024-03-31 15:37:22 +02:00
Jithil P Ponnan
64f7d0e0bd
test: fix flakiness in worker*.test-free-called
The issue arises from the `getFreeCallCount()` function yielding the
initial value of 0. Upon instantiation of the `Worker` object, it
increments to 1. In the case of this flaky test, if the creation of the
`Worker` object is faster, the subsequent `getFreeCallCount()` call
always returns 1 instead of the expected 0.

Fixes: https://github.com/nodejs/node/issues/51003
PR-URL: https://github.com/nodejs/node/pull/51013
Reviewed-By: Vinícius Lourenço Claro Cardoso <contact@viniciusl.com.br>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-12-19 17:11:27 +00:00
Livia Medeiros
052434a0c1
test: use tmpdir.resolve()
PR-URL: https://github.com/nodejs/node/pull/49136
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-08-21 16:41:53 +00:00
Daryl Haresign
7f2c810814
src,tools: initialize cppgc
This patch:

- Initializes cppgc in InitializeOncePerProcess() when
  kNoInitializeCppgc is not set
- Create a CppHeap and attach it to the Isolate when
  there isn't one already during IsolateData initialization.
  The CppHeap is detached and terminated when IsolateData
  is freed.
- Publishes the cppgc headers in the tarball.

This allows C++ addons to start using cppgc to manage objects.

A helper node::SetCppgcReference() is also added to help addons
enable cppgc tracing in a user-defined object.

Co-authored-by: Joyee Cheung <joyeec9h3@gmail.com>
Refs: https://github.com/nodejs/node/issues/40786
PR-URL: https://github.com/nodejs/node/pull/45704
Refs: https://docs.google.com/document/d/1ny2Qz_EsUnXGKJRGxoA-FXIE2xpLgaMAN6jD7eAkqFQ/edit
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2023-08-11 00:43:51 +00:00
Chengzhong Wu
a509753a8e
report: disable js stack when no context is entered
There are no guarantees that the JS stack can be generated when no
context is entered.

PR-URL: https://github.com/nodejs/node/pull/48495
Fixes: https://github.com/nodejs/node-v8/issues/250
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/4582948
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2023-06-21 13:58:15 +00:00
Chengzhong Wu
64549731b6
src: throw DataCloneError on transfering untransferable objects
The HTML StructuredSerializeWithTransfer algorithm defines that when
an untransferable object is in the transfer list, a DataCloneError is
thrown.
An array buffer that is already transferred is also considered as
untransferable.

PR-URL: https://github.com/nodejs/node/pull/47604
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-05-05 11:22:42 +00:00
Rafael Gonzaga
00c222593e
src,process: add permission model
Signed-off-by: RafaelGSS <rafael.nunu@hotmail.com>
PR-URL: https://github.com/nodejs/node/pull/44004
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2023-02-23 18:11:51 +00:00
Xu Meng
a3211e18b4
build,test: add proper support for IBM i
Python 3.9 on IBM i now properly returns "os400" for sys.platform
instead of claiming to be AIX as it did previously. While the IBM i PASE
environment is compatible with AIX, it is a subset and has numerous
differences which makes it beneficial to distinguish, however this means
that it now needs explicit support here.

PR-URL: https://github.com/nodejs/node/pull/46739
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2023-02-22 04:18:56 +00:00
Mohamed Akram
3abd559c6a
build: export more OpenSSL symbols on Windows
PR-URL: https://github.com/nodejs/node/pull/45486
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
2023-01-31 07:19:01 +00:00
Anna Henningsen
43e09af8e6
src: fix creating Isolates from addons
daae938f32 broke addons which create their own `Isolate`
instances, because enabling the shared-readonly-heap feature
of V8 requires all snapshots used for different `Isolate`s to
be identical. Usage of addons that do this has probably
decreased quite a bit since Worker threads were introduced
in Node.js, but it’s still a valid use case, and in any case
the breakage was probably not intentional (although the referenced
commit did require test changes because of this issue).

This commit addresses this issue partially by caching the
V8 snapshot parameters and ignoring ones passed in from users
in `NewIsolate()` when this feature is enabled, and makes
the `NodeMainInstance` snapshot-based isolate creation
also re-use this code.

PR-URL: https://github.com/nodejs/node/pull/45885
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-12-23 17:06:05 +00:00
Santiago Gimeno
f02bdbf6a3
test: fix -Wunused-variable on report-fatalerror
PR-URL: https://github.com/nodejs/node/pull/45747
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-12-08 00:00:45 +00:00
Antoine du Hamel
4f20c882ec
test: add trailing commas in addons test (#45548)
PR-URL: https://github.com/nodejs/node/pull/45548
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2022-11-21 18:40:12 +01:00
Santiago Gimeno
09cbb66f04
test: use uv_sleep() where possible
PR-URL: https://github.com/nodejs/node/pull/45124
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: theanarkh <theratliter@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2022-10-27 17:13:50 +00:00
Richard Lau
50aac703f3
test: skip some binding tests on IBMi PASE
IBM i PASE Node.js always links to shared openssl
libraries. Skip recently added OpenSSL addons
tests as we do for other OpenSSL addons tests on
IBM i.

Refs: https://github.com/nodejs/node/pull/31967
Refs: https://github.com/nodejs/node/pull/44148
PR-URL: https://github.com/nodejs/node/pull/44810
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-02 22:41:21 +00:00
Joyee Cheung
a16f81eed7
test: remove unused variable in addon test
This fixes the compiler warning for the unused variable in the
report-api addon test.

PR-URL: https://github.com/nodejs/node/pull/44809
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2022-10-02 13:10:46 +00:00
Adam Majer
456591829b
test: fix addon tests compilation with OpenSSL 1.1.1
openssl/provider.h header is not part of OpenSSL 1.1.1 so do not
include it when building with an older instance.

Fixes: https://github.com/nodejs/node/issues/44722
PR-URL: https://github.com/nodejs/node/pull/44725
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-09-22 23:19:44 +00:00
Tony Gorez
112a231fab
test: add more cases for parse-encoding
PR-URL: https://github.com/nodejs/node/pull/44427
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
2022-09-06 06:20:16 +00:00
Chengzhong Wu
f7896d4671 report: get stack trace with cross origin contexts
When a new context with a different security token is entered, or
when no context is entered, `StackTrace::CurrentStackTrace` need to
be explicitly set with flag `kExposeFramesAcrossSecurityOrigins` to
avoid crashing.

PR-URL: https://github.com/nodejs/node/pull/44398
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2022-09-02 14:02:00 +08:00
legendecas
4f6f90f536 src: expose environment RequestInterrupt api
Allow add-ons to interrupt JavaScript execution, and wake up loop if it
is currently idle.

PR-URL: https://github.com/nodejs/node/pull/44362
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2022-09-01 17:01:00 +08:00
Chengzhong Wu
cb15fc56d8
report: expose report public native apis
Allows APM vendors to generate a diagnostic report without calling into
JavaScript. Like, from their own message channels interrupting the
isolate and generating a report on demand.

PR-URL: https://github.com/nodejs/node/pull/44255
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2022-08-24 17:02:26 +00:00
Richard Lau
53ec358606
test: add OpenSSL 3.x providers test
Add basic tests for providers when using OpenSSL 3.x.

PR-URL: https://github.com/nodejs/node/pull/44148
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2022-08-24 14:31:32 +00:00
legendecas
466710c298
report: print javascript stack on fatal error
Try to print JavaScript stack on fatal error. OOMError needs to be
distinguished from fatal error since no new handle can be created at
that time.

PR-URL: https://github.com/nodejs/node/pull/44242
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2022-08-20 12:34:34 +08:00
Joyee Cheung
472edc775d
src: disambiguate terms used to refer to builtins and addons
The term "native module" dates back to some of the oldest code
in the code base. Within the context of Node.js core it usually
refers to modules that are native to Node.js (e.g. fs, http),
but it can cause confusion for people who don't work on this
part of the code base, as "native module" can also refer to
native addons - which is even the case in some of the API
docs and error messages.

This patch tries to make the usage of these terms more consistent.
Now within the context of Node.js core:

- JavaScript scripts that are built-in to Node.js are now referred
  to as "built-in(s)". If they are available as modules,
  they can also be referred to as "built-in module(s)".
- Dynamically-linked shared objects that are loaded into
  the Node.js processes are referred to as "addons".

We will try to avoid using the term "native modules" because it could
be ambiguous.

Changes in this patch:

File names:
- node_native_module.h -> node_builtins.h,
- node_native_module.cc -> node_builtins.cc

C++ binding names:
- `native_module` -> `builtins`

`node::Environment`:
- `native_modules_without_cache` -> `builtins_without_cache`
- `native_modules_with_cache` -> `builtins_with_cache`
- `native_modules_in_snapshot` -> `builtins_in_cache`
- `native_module_require` -> `builtin_module_require`

`node::EnvSerializeInfo`:
- `native_modules` -> `builtins

`node::native_module::NativeModuleLoader`:
- `native_module` namespace -> `builtins` namespace
- `NativeModuleLoader` -> `BuiltinLoader`
- `NativeModuleRecordMap` -> `BuiltinSourceMap`
- `NativeModuleCacheMap` -> `BuiltinCodeCacheMap`
- `ModuleIds` -> `BuiltinIds`
- `ModuleCategories` -> `BuiltinCategories`
- `LoadBuiltinModuleSource` -> `LoadBuiltinSource`

`loader.js`:
- `NativeModule` -> `BuiltinModule` (the `NativeModule` name used in
  `process.moduleLoadList` is kept for compatibility)

And other clarifications in the documentation and comments.

PR-URL: https://github.com/nodejs/node/pull/44135
Fixes: https://github.com/nodejs/node/issues/44036
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
2022-08-09 01:36:49 +08:00
Michael Dawson
5f348b4572 test: move test-crypto-engine to addon
Fixes: https://github.com/nodejs/node/issues/41633
Fixes: https://github.com/nodejs/node/issues/40958

- move test-crypto-engine so that dummy engine
  is only built if tests are run

Signed-off-by: Michael Dawson <mdawson@devrus.com>

PR-URL: https://github.com/nodejs/node/pull/41830
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-07 17:29:54 -05:00
Rich Trott
5d559f4a74 test: enable no-empty ESLint rule
PR-URL: https://github.com/nodejs/node/pull/41831
Refs: https://eslint.org/docs/rules/no-empty
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-02-05 12:58:32 +00:00
Rich Trott
55ceaec111 tools,benchmark,lib,test: enable no-case-declarations lint rule
PR-URL: https://github.com/nodejs/node/pull/41385
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Tierney Cyren <hello@bnb.im>
Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2022-01-05 07:42:19 -08:00
Dominic Elm
a9dd03b1ec src: add option to disable loading native addons
PR-URL: https://github.com/nodejs/node/pull/39977
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
2021-09-10 10:54:39 -05:00
Michaël Zasso
508890d795
test: use assert.match instead of regexp.test
PR-URL: https://github.com/nodejs/node/pull/39928
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
2021-08-31 18:50:16 +02:00
Stephen Belanger
84dfa1f3e3 async_hooks: eliminate native PromiseHook
PR-URL: https://github.com/nodejs/node/pull/39135
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
2021-07-23 03:54:31 +00:00
Rich Trott
330f25ef82 test: prepare for consistent comma-dangle lint rule
Make changes so that tests will pass when the comma-dangle settings
applied to the rest of the code base are also applied to tests.

PR-URL: https://github.com/nodejs/node/pull/37930
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
2021-04-01 23:14:29 -07:00
Rich Trott
978594c706 test: make status file names consistent
For some reason, the test/addons directory has a status file of
addon.status rather than addons.status. Make it consistent with other
directories.

PR-URL: https://github.com/nodejs/node/pull/37532
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2021-03-01 12:18:18 -08:00
Richard Lau
863ec7dbaa test: mark flaky tests on IBM i
PR-URL: https://github.com/nodejs/node/pull/36986
Refs: https://github.com/nodejs/node/issues/34410
Refs: https://github.com/nodejs/node/issues/36925
Refs: https://github.com/nodejs/node/issues/36929
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-19 06:41:39 -08:00
Filip Skokan
f8ab632d56 buffer: add base64url encoding option
PR-URL: https://github.com/nodejs/node/pull/36952
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2021-01-18 12:08:20 +01:00
Rich Trott
5122456883 test: fix comment misspellings of transferred
PR-URL: https://github.com/nodejs/node/pull/36360
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Zeyu Yang <himself65@outlook.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2020-12-07 07:31:58 -08:00
Anna Henningsen
b3b0c43474 domain: improve deprecation warning text for DEP0097
Because the following gives basically no actionable information
on its own, neither in the error message nor in the stack trace:

    (node:3187) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
        at emitMakeCallbackDeprecation (domain.js:123:13)
        at process.topLevelDomainCallback (domain.js:135:5)
        at process.callbackTrampoline (internal/async_hooks.js:124:14)

PR-URL: https://github.com/nodejs/node/pull/36136
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-11-18 18:58:49 +00:00
Rich Trott
4fb780334d doc,src,test: revise C++ code for linter update
PR-URL: https://github.com/nodejs/node/pull/35719
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2020-10-23 03:47:50 -07:00
Myles Borins
089d654dd8 test: fix addons/dlopen-ping-pong for npm 7.0.1
This partially reverts c87641aa97 as node-gyp no longer
puts shared objects in an inconsistent location.

PR-URL: https://github.com/nodejs/node/pull/35667
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
2020-10-18 17:17:42 +00:00
Myles Borins
c87641aa97
test: fix test suite to work with npm 7
PR-URL: https://github.com/nodejs/node/pull/35474
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Ujjwal Sharma <ryzokuken@disroot.org>
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Geoffrey Booth <webmaster@geoffreybooth.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2020-10-07 09:59:51 -04:00
Anna Henningsen
bfebfdb149 src: fix linter failures
Fix linter failures when running the linter on all source files.

PR-URL: https://github.com/nodejs/node/pull/34582
Refs: https://github.com/nodejs/node/pull/34565
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-08-07 08:43:17 -07:00
Anna Henningsen
22cbbcf9d9
n-api,src: provide asynchronous cleanup hooks
Sometimes addons need to perform cleanup actions, for example
closing libuv handles or waiting for requests to finish, that
cannot be performed synchronously.

Add C++ API and N-API functions that allow providing such
asynchronous cleanup hooks.

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

PR-URL: https://github.com/nodejs/node/pull/34572
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
2020-08-07 00:02:02 +02:00
Anna Henningsen
a038199265
src,doc,test: remove String::New default parameter
`kNormal` has been the implicit default for a while now (since V8 7.6).

Refs: e0d7f81699

PR-URL: https://github.com/nodejs/node/pull/34248
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-07-14 15:13:34 +02:00
sapics
bc23d108c8
src: fix ParseEncoding
"utf-16LE" was parsed "UNKNOWN", this fixes to "UCS2"
"utf-buffer" was parsed "BUFFER", this fixes to "UNKNOWN"
"utf-16leNOT" was parsed "UCS2", this fixes to "UNKNOWN"

PR-URL: https://github.com/nodejs/node/pull/33957
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-06-25 09:14:23 -07:00
Anna Henningsen
0fb91acedf
src: disallow JS execution inside FreeEnvironment
This addresses a TODO comment, and aligns the behavior between
worker threads and the main thread.

The primary motivation for this change is to more strictly enforce
the invariant that no JS runs after the `'exit'` event is emitted.

PR-URL: https://github.com/nodejs/node/pull/33874
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
2020-06-24 17:43:29 -07:00
Anna Henningsen
c1ee70ec16
buffer,n-api: release external buffers from BackingStore callback
Release `Buffer` and `ArrayBuffer` instances that were created through
our addon APIs and have finalizers attached to them only after V8 has
called the deleter callback passed to the `BackingStore`, instead of
relying on our own GC callback(s).

This fixes the following race condition:

1. Addon code allocates pointer P via `malloc`.
2. P is passed into `napi_create_external_buffer` with a finalization
   callback which calls `free(P)`. P is inserted into V8’s global array
   buffer table for tracking.
3. The finalization callback is executed on GC. P is freed and returned
   to the allocator. P is not yet removed from V8’s global array
   buffer table. (!)
4. Addon code attempts to allocate memory once again. The allocator
   returns P, as it is now available.
5. P is passed into `napi_create_external_buffer`. P still has not been
   removed from the v8 global array buffer table.
6. The world ends with `Check failed: result.second`.

Since our API contract is to call the finalizer on the JS thread on
which the `ArrayBuffer` was created, but V8 may call the `BackingStore`
deleter callback on another thread, fixing this requires posting
a task back to the JS thread.

Refs: https://github.com/nodejs/node/issues/32463#issuecomment-625877175
Fixes: https://github.com/nodejs/node/issues/32463

PR-URL: https://github.com/nodejs/node/pull/33321
Reviewed-By: James M Snell <jasnell@gmail.com>
2020-05-16 12:15:07 +02:00