Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmark/napi/function_args/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Show the difference between calling a V8 binding C++ function
// relative to a comparable N-API C++ function,
// relative to a comparable Node-API C++ function,
// in various types/numbers of arguments.
// Reports n of calls per second.
'use strict';
Expand All @@ -19,7 +19,7 @@ try {
try {
napi = require(`./build/${common.buildType}/napi_binding`);
} catch {
console.error(`${__filename}: NAPI-Binding failed to load`);
console.error(`${__filename}: Node-API binding failed to load`);
process.exit(0);
}

Expand Down
2 changes: 1 addition & 1 deletion benchmark/napi/function_call/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ let napi_binding;
try {
napi_binding = require(`./build/${common.buildType}/napi_binding`);
} catch {
console.error('misc/function_call/index.js NAPI-Binding failed to load');
console.error('misc/function_call/index.js Node-API binding failed to load');
process.exit(0);
}
const napi = napi_binding.hello;
Expand Down
47 changes: 24 additions & 23 deletions doc/contributing/security-release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,30 @@ steps listed in the process as outlined in
The current security stewards are documented in the main Node.js
[README.md](https://github.com/nodejs/node#security-release-stewards).

| Company | Person | Release Date |
| ------------ | --------------- | ------------ |
| NearForm | Matteo | 2021-Oct-12 |
| Datadog | Bryan | 2022-Jan-10 |
| RH and IBM | Joe | 2022-Mar-18 |
| NearForm | Matteo / Rafael | 2022-Jul-07 |
| Datadog | Vladimir | 2022-Sep-23 |
| NodeSource | Juan | 2022-Nov-04 |
| RH and IBM | Michael | 2023-Feb-16 |
| NearForm | Rafael | 2023-Jun-20 |
| NearForm | Rafael | 2023-Aug-09 |
| NearForm | Rafael | 2023-Oct-13 |
| NodeSource | Rafael | 2024-Feb-14 |
| NodeSource | Rafael | 2024-Apr-03 |
| NodeSource | Rafael | 2024-Apr-10 |
| NodeSource | Rafael | 2024-Jul-08 |
| NodeSource | Rafael | 2025-Jan-21 |
| NodeSource | Rafael | 2025-May-14 |
| NodeSource | Rafael | 2025-July-15 |
| Datadog | Bryan | |
| IBM | Joe | |
| Platformatic | Matteo | |
| NodeSource | Juan | |
| Company | Person | Release Date |
| ----------------------- | --------------- | ------------ |
| NearForm | Matteo | 2021-Oct-12 |
| Datadog | Bryan | 2022-Jan-10 |
| RH and IBM | Joe | 2022-Mar-18 |
| NearForm | Matteo / Rafael | 2022-Jul-07 |
| Datadog | Vladimir | 2022-Sep-23 |
| NodeSource | Juan | 2022-Nov-04 |
| RH and IBM | Michael | 2023-Feb-16 |
| NearForm | Rafael | 2023-Jun-20 |
| NearForm | Rafael | 2023-Aug-09 |
| NearForm | Rafael | 2023-Oct-13 |
| NodeSource | Rafael | 2024-Feb-14 |
| NodeSource | Rafael | 2024-Apr-03 |
| NodeSource | Rafael | 2024-Apr-10 |
| NodeSource | Rafael | 2024-Jul-08 |
| NodeSource | Rafael | 2025-Jan-21 |
| NodeSource | Rafael | 2025-May-14 |
| NodeSource | Rafael | 2025-Jul-15 |
| HeroDevs and NodeSource | Marco / Rafael | 2026-Jan-13 |
| Datadog | Bryan | |
| IBM | Joe | |
| Platformatic | Matteo | |
| NodeSource | Juan | |

## Planning

Expand Down
7 changes: 0 additions & 7 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ function openAsBlob(path, options = kEmptyObject) {
*/
function read(fd, buffer, offsetOrOptions, length, position, callback) {
fd = getValidatedFd(fd);

let offset = offsetOrOptions;
let params = null;
if (arguments.length <= 4) {
Expand Down Expand Up @@ -689,8 +688,6 @@ ObjectDefineProperty(read, kCustomPromisifyArgsSymbol,
* @returns {number}
*/
function readSync(fd, buffer, offsetOrOptions, length, position) {
fd = getValidatedFd(fd);

validateBuffer(buffer);

let offset = offsetOrOptions;
Expand Down Expand Up @@ -779,7 +776,6 @@ ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol,
* @returns {number}
*/
function readvSync(fd, buffers, position) {
fd = getValidatedFd(fd);
validateBufferArray(buffers);

if (typeof position !== 'number')
Expand Down Expand Up @@ -809,7 +805,6 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
}

fd = getValidatedFd(fd);

let offset = offsetOrOptions;
if (isArrayBufferView(buffer)) {
callback ||= position || length || offset;
Expand Down Expand Up @@ -880,7 +875,6 @@ ObjectDefineProperty(write, kCustomPromisifyArgsSymbol,
* @returns {number}
*/
function writeSync(fd, buffer, offsetOrOptions, length, position) {
fd = getValidatedFd(fd);
const ctx = {};
let result;

Expand Down Expand Up @@ -970,7 +964,6 @@ ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, {
* @returns {number}
*/
function writevSync(fd, buffers, position) {
fd = getValidatedFd(fd);
validateBufferArray(buffers);

if (buffers.length === 0) {
Expand Down
9 changes: 2 additions & 7 deletions lib/internal/test_runner/reporter/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SpecReporter extends Transform {
}

this.#failedTests = []; // Clean up the failed tests
return ArrayPrototypeJoin(results, '\n'); ;
return ArrayPrototypeJoin(results, '\n');
}
#handleTestReportEvent(type, data) {
const subtest = ArrayPrototypeShift(this.#stack); // This is the matching `test:start` event
Expand All @@ -71,13 +71,8 @@ class SpecReporter extends Transform {
ArrayPrototypeUnshift(this.#reported, msg);
prefix += `${indent(msg.nesting)}${reporterUnicodeSymbolMap['arrow:right']}${msg.name}\n`;
}
let hasChildren = false;
if (this.#reported[0] && this.#reported[0].nesting === data.nesting && this.#reported[0].name === data.name) {
ArrayPrototypeShift(this.#reported);
hasChildren = true;
}
const indentation = indent(data.nesting);
return `${formatTestReport(type, data, prefix, indentation, hasChildren, false)}\n`;
return `${formatTestReport(type, data, false, prefix, indentation)}\n`;
}
#handleEvent({ type, data }) {
switch (type) {
Expand Down
8 changes: 2 additions & 6 deletions lib/internal/test_runner/reporter/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ function indent(nesting) {
}

function formatError(error, indent) {
if (!error) return '';
const err = error.code === 'ERR_TEST_FAILURE' ? error.cause : error;
const message = ArrayPrototypeJoin(
RegExpPrototypeSymbolSplit(
Expand All @@ -68,7 +67,7 @@ function formatError(error, indent) {
return `\n${indent} ${message}\n`;
}

function formatTestReport(type, data, prefix = '', indent = '', hasChildren = false, showErrorDetails = true) {
function formatTestReport(type, data, showErrorDetails = true, prefix = '', indent = '') {
let color = reporterColorMap[type] ?? colors.white;
let symbol = reporterUnicodeSymbolMap[type] ?? ' ';
const { skip, todo, expectFailure } = data;
Expand All @@ -83,10 +82,7 @@ function formatTestReport(type, data, prefix = '', indent = '', hasChildren = fa
title += ` # EXPECTED FAILURE`;
}

const error = showErrorDetails ? formatError(data.details?.error, indent) : '';
const err = hasChildren ?
(!error || data.details?.error?.failureType === 'subtestsFailed' ? '' : `\n${error}`) :
error;
const err = showErrorDetails && data.details?.error ? formatError(data.details.error, indent) : '';

if (skip !== undefined) {
color = colors.gray;
Expand Down
13 changes: 6 additions & 7 deletions src/js_native_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
#ifdef NAPI_EXPERIMENTAL
#define NAPI_VERSION NAPI_VERSION_EXPERIMENTAL
#else
// The baseline version for N-API.
// The NAPI_VERSION controls which version will be used by default when
// compilling a native addon. If the addon developer specifically wants to use
// functions available in a new version of N-API that is not yet ported in all
// LTS versions, they can set NAPI_VERSION knowing that they have specifically
// depended on that version.
// The baseline version for Node-API.
// NAPI_VERSION controls which version is used by default when compiling
// a native addon. If the addon developer wants to use functions from a
// newer Node-API version not yet available in all LTS versions, they can
// set NAPI_VERSION to explicitly depend on that version.
#define NAPI_VERSION 8
#endif
#endif
Expand All @@ -31,7 +30,7 @@

// This file needs to be compatible with C compilers.
// This is a public include file, and these includes have essentially
// became part of it's API.
// become part of its API.
#include <stddef.h> // NOLINT(modernize-deprecated-headers)
#include <stdint.h> // NOLINT(modernize-deprecated-headers)

Expand Down
17 changes: 8 additions & 9 deletions src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define CHECK_TO_NUMBER(env, context, result, src) \
CHECK_TO_TYPE((env), Number, (context), (result), (src), napi_number_expected)

// n-api defines NAPI_AUTO_LENGTH as the indicator that a string
// Node-API defines NAPI_AUTO_LENGTH as the indicator that a string
// is null terminated. For V8 the equivalent is -1. The assert
// validates that our cast of NAPI_AUTO_LENGTH results in -1 as
// needed by V8.
Expand Down Expand Up @@ -225,7 +225,7 @@ inline napi_status V8NameFromPropertyDescriptor(
return napi_ok;
}

// convert from n-api property attributes to v8::PropertyAttribute
// convert from Node-API property attributes to v8::PropertyAttribute
inline v8::PropertyAttribute V8PropertyAttributesFromDescriptor(
const napi_property_descriptor* descriptor) {
unsigned int attribute_flags = v8::PropertyAttribute::None;
Expand Down Expand Up @@ -378,11 +378,10 @@ inline napi_status Unwrap(napi_env env,

//=== Function napi_callback wrapper =================================

// Use this data structure to associate callback data with each N-API function
// exposed to JavaScript. The structure is stored in a v8::External which gets
// passed into our callback wrapper. This reduces the performance impact of
// calling through N-API.
// Ref: benchmark/misc/function_call
// Use this data structure to associate callback data with each Node-API
// function exposed to JavaScript. The structure is stored in a v8::External
// which gets passed into our callback wrapper. This reduces the performance
// impact of calling through Node-API. Ref: benchmark/misc/function_call
// Discussion (incl. perf. data): https://github.com/nodejs/node/pull/21072
class CallbackBundle {
public:
Expand All @@ -407,7 +406,7 @@ class CallbackBundle {
}

public:
napi_env env; // Necessary to invoke C++ NAPI callback
napi_env env; // Necessary to invoke C++ Node-API callback
void* cb_data; // The user provided callback data
napi_callback cb;

Expand Down Expand Up @@ -2126,7 +2125,7 @@ napi_status NAPI_CDECL napi_get_null(napi_env env, napi_value* result) {

// Gets all callback info in a single call. (Ugly, but faster.)
napi_status NAPI_CDECL napi_get_cb_info(
napi_env env, // [in] NAPI environment handle
napi_env env, // [in] Node-API environment handle
napi_callback_info cbinfo, // [in] Opaque callback-info handle
size_t* argc, // [in-out] Specifies the size of the provided argv array
// and receives the actual count of args.
Expand Down
12 changes: 6 additions & 6 deletions src/js_native_api_v8_internals.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#ifndef SRC_JS_NATIVE_API_V8_INTERNALS_H_
#define SRC_JS_NATIVE_API_V8_INTERNALS_H_

// The V8 implementation of N-API, including `js_native_api_v8.h` uses certain
// idioms which require definition here. For example, it uses a variant of
// persistent references which need not be reset in the constructor. It is the
// responsibility of this file to define these idioms. Optionally, this file
// may also define `NAPI_VERSION` and set it to the version of N-API to be
// The V8 implementation of Node-API, including `js_native_api_v8.h` uses
// certain idioms which require definition here. For example, it uses a variant
// of persistent references which need not be reset in the constructor. It is
// the responsibility of this file to define these idioms. Optionally, this file
// may also define `NAPI_VERSION` and set it to the version of Node-API to be
// exposed.

// In the case of the Node.js implementation of N-API some of the idioms are
// In the case of the Node.js implementation of Node-API some of the idioms are
// imported directly from Node.js by including `node_internals.h` below. Others
// are bridged to remove references to the `node` namespace. `node_version.h`,
// included below, defines `NAPI_VERSION`.
Expand Down
14 changes: 7 additions & 7 deletions src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ static void ThrowNodeApiVersionError(node::Environment* node_env,
result = new node_napi_env__(context, module_filename, module_api_version);
// TODO(addaleax): There was previously code that tried to delete the
// napi_env when its v8::Context was garbage collected;
// However, as long as N-API addons using this napi_env are in place,
// However, as long as Node-API addons using this napi_env are in place,
// the Context needs to be accessible and alive.
// Ideally, we'd want an on-addon-unload hook that takes care of this
// once all N-API addons using this napi_env are unloaded.
// once all Node-API addons using this napi_env are unloaded.
// For now, a per-Environment cleanup hook is the best we can do.
result->node_env()->AddCleanupHook(
[](void* arg) { static_cast<napi_env>(arg)->Unref(); },
Expand Down Expand Up @@ -150,7 +150,7 @@ void node_napi_env__::CallbackIntoModule(T&& call) {
!enforceUncaughtExceptionPolicy) {
ProcessEmitDeprecationWarning(
node_env,
"Uncaught N-API callback exception detected, please run node "
"Uncaught Node-API callback exception detected, please run node "
"with option --force-node-api-uncaught-exceptions-policy=true "
"to handle those exceptions properly.",
"DEP0168");
Expand Down Expand Up @@ -675,8 +675,8 @@ class AsyncContext {
} // end of namespace v8impl

// Intercepts the Node-V8 module registration callback. Converts parameters
// to NAPI equivalents and then calls the registration callback specified
// by the NAPI module.
// to Node-API equivalents and then calls the registration callback specified
// by the Node-API module.
static void napi_module_register_cb(v8::Local<v8::Object> exports,
v8::Local<v8::Value> module,
v8::Local<v8::Context> context,
Expand Down Expand Up @@ -796,7 +796,7 @@ node_module napi_module_to_node_module(const napi_module* mod) {
}
} // namespace node

// Registers a NAPI module.
// Registers a Node-API module.
void NAPI_CDECL napi_module_register(napi_module* mod) {
node::node_module* nm =
new node::node_module(node::napi_module_to_node_module(mod));
Expand Down Expand Up @@ -839,7 +839,7 @@ struct napi_async_cleanup_hook_handle__ {
if (done_cb_ != nullptr) done_cb_(done_data_);

// Release the `env` handle asynchronously since it would be surprising if
// a call to a N-API function would destroy `env` synchronously.
// a call to a Node-API function would destroy `env` synchronously.
static_cast<node_napi_env>(env_)->node_env()->SetImmediate(
[env = env_](node::Environment*) { env->Unref(); });
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ void DLOpen(const FunctionCallbackInfo<Value>& args) {
}
}

// -1 is used for N-API modules
// -1 is used for Node-API modules
if ((mp->nm_version != -1) && (mp->nm_version != NODE_MODULE_VERSION)) {
// Even if the module did self-register, it may have done so with the
// wrong version. We must only give up after having checked to see if it
Expand Down
Loading
Loading