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
6 changes: 4 additions & 2 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ Refs:

##### Option 1: Manual install

* The current [version of Python][Python versions] from the
[Microsoft Store](https://apps.microsoft.com/store/search?publisher=Python+Software+Foundation)
* The current [version of Python][Python downloads] by following the instructions in
[Using Python on Windows][].
* The "Desktop development with C++" workload from
[Visual Studio 2022 (17.13 or newer)](https://visualstudio.microsoft.com/downloads/)
or the "C++ build tools" workload from the
Expand Down Expand Up @@ -1146,4 +1146,6 @@ by opening a pull request against the registry available at

[AIX toolbox]: https://www.ibm.com/support/pages/aix-toolbox-open-source-software-overview
[Developer Mode]: https://learn.microsoft.com/en-us/windows/advanced-settings/developer-mode
[Python downloads]: https://www.python.org/downloads/
[Python versions]: https://devguide.python.org/versions/
[Using Python on Windows]: https://docs.python.org/3/using/windows.html
2 changes: 2 additions & 0 deletions deps/googletest/include/gtest/internal/gtest-port-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
#define GTEST_OS_NXP_QN9090 1
#elif defined(NRF52)
#define GTEST_OS_NRF52 1
#elif defined(__EMSCRIPTEN__)
#define GTEST_OS_EMSCRIPTEN 1
#endif // __CYGWIN__

#endif // GOOGLETEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_ARCH_H_
22 changes: 16 additions & 6 deletions deps/googletest/include/gtest/internal/gtest-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,12 +664,22 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
defined(GTEST_OS_NETBSD) || defined(GTEST_OS_FUCHSIA) || \
defined(GTEST_OS_DRAGONFLY) || defined(GTEST_OS_GNU_KFREEBSD) || \
defined(GTEST_OS_HAIKU) || defined(GTEST_OS_GNU_HURD))

// Death tests require a file system to work properly.
#if GTEST_HAS_FILE_SYSTEM
#define GTEST_HAS_DEATH_TEST 1
#endif // GTEST_HAS_FILE_SYSTEM
#endif

// Determines whether the Premature Exit file can be created.
// Created by default when Death tests are supported, but other platforms can
// use the Premature exit file without Death test support (e.g. for detecting
// crashes).
#if GTEST_HAS_DEATH_TEST || \
(defined(GTEST_OS_EMSCRIPTEN) && GTEST_HAS_FILE_SYSTEM)
#define GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE 1
#endif

// Determines whether to support type-driven tests.

// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,
Expand Down Expand Up @@ -822,10 +832,10 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#ifndef GTEST_API_

#ifdef _MSC_VER
#if defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY
#define GTEST_API_ __declspec(dllimport)
#elif defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY
#if defined(GTEST_CREATE_SHARED_LIBRARY) && GTEST_CREATE_SHARED_LIBRARY
#define GTEST_API_ __declspec(dllexport)
#elif defined(GTEST_LINKED_AS_SHARED_LIBRARY) && GTEST_LINKED_AS_SHARED_LIBRARY
#define GTEST_API_ __declspec(dllimport)
#endif
#elif GTEST_INTERNAL_HAVE_CPP_ATTRIBUTE(gnu::visibility)
#define GTEST_API_ [[gnu::visibility("default")]]
Expand Down Expand Up @@ -2242,11 +2252,11 @@ using TimeInMillis = int64_t; // Represents time in milliseconds.

// Macros for declaring flags.
#define GTEST_DECLARE_bool_(name) \
ABSL_DECLARE_FLAG(bool, GTEST_FLAG_NAME_(name))
GTEST_API_ ABSL_DECLARE_FLAG(bool, GTEST_FLAG_NAME_(name))
#define GTEST_DECLARE_int32_(name) \
ABSL_DECLARE_FLAG(int32_t, GTEST_FLAG_NAME_(name))
GTEST_API_ ABSL_DECLARE_FLAG(int32_t, GTEST_FLAG_NAME_(name))
#define GTEST_DECLARE_string_(name) \
ABSL_DECLARE_FLAG(std::string, GTEST_FLAG_NAME_(name))
GTEST_API_ ABSL_DECLARE_FLAG(std::string, GTEST_FLAG_NAME_(name))

#define GTEST_FLAG_SAVER_ ::absl::FlagSaver

Expand Down
8 changes: 4 additions & 4 deletions deps/googletest/src/gtest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5132,7 +5132,7 @@ void OsStackTraceGetter::UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_) {
#endif // GTEST_HAS_ABSL
}

#ifdef GTEST_HAS_DEATH_TEST
#ifdef GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE
// A helper class that creates the premature-exit file in its
// constructor and deletes the file in its destructor.
class ScopedPrematureExitFile {
Expand Down Expand Up @@ -5170,7 +5170,7 @@ class ScopedPrematureExitFile {
ScopedPrematureExitFile(const ScopedPrematureExitFile&) = delete;
ScopedPrematureExitFile& operator=(const ScopedPrematureExitFile&) = delete;
};
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE

} // namespace internal

Expand Down Expand Up @@ -5515,7 +5515,7 @@ void UnitTest::RecordProperty(const std::string& key,
// We don't protect this under mutex_, as we only support calling it
// from the main thread.
int UnitTest::Run() {
#ifdef GTEST_HAS_DEATH_TEST
#ifdef GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE
const bool in_death_test_child_process =
!GTEST_FLAG_GET(internal_run_death_test).empty();

Expand Down Expand Up @@ -5546,7 +5546,7 @@ int UnitTest::Run() {
: internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE"));
#else
const bool in_death_test_child_process = false;
#endif // GTEST_HAS_DEATH_TEST
#endif // GTEST_INTERNAL_HAS_PREMATURE_EXIT_FILE

// Captures the value of GTEST_FLAG(catch_exceptions). This value will be
// used for the duration of the program.
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 14
#define V8_MINOR_VERSION 3
#define V8_BUILD_NUMBER 127
#define V8_PATCH_LEVEL 17
#define V8_PATCH_LEVEL 18

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/codegen/arm64/assembler-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4968,7 +4968,7 @@ void Assembler::CheckVeneerPool(bool force_emit, bool require_jump,
return;
}

CHECK_LT(pc_offset(), unresolved_branches_first_limit());
DCHECK(pc_offset() < unresolved_branches_first_limit());

// Some short sequence of instruction mustn't be broken up by veneer pool
// emission, such sequences are protected by calls to BlockVeneerPoolFor and
Expand Down
5 changes: 4 additions & 1 deletion doc/api/sqlite.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ exposed by this class execute synchronously.
<!-- YAML
added: v22.5.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/61266
description: Enable `defensive` by default.
- version:
- v25.1.0
- v24.12.0
Expand Down Expand Up @@ -154,7 +157,7 @@ changes:
* `defensive` {boolean} If `true`, enables the defensive flag. When the defensive flag is enabled,
language features that allow ordinary SQL to deliberately corrupt the database file are disabled.
The defensive flag can also be set using `enableDefensive()`.
**Default:** `false`.
**Default:** `true`.

Constructs a new `DatabaseSync` instance.

Expand Down
133 changes: 59 additions & 74 deletions lib/internal/modules/package_json_reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ const {
ObjectDefineProperty,
RegExpPrototypeExec,
SafeMap,
StringPrototypeEndsWith,
StringPrototypeIndexOf,
StringPrototypeLastIndexOf,
StringPrototypeSlice,
} = primordials;
const {
Expand All @@ -28,11 +26,9 @@ const {
const { kEmptyObject } = require('internal/util');
const modulesBinding = internalBinding('modules');
const path = require('path');
const permission = require('internal/process/permission');
const { validateString } = require('internal/validators');
const internalFsBinding = internalBinding('fs');

const nearestParentPackageJSONCache = new SafeMap();

/**
* @typedef {import('typings/internalBinding/modules').DeserializedPackageConfig} DeserializedPackageConfig
Expand Down Expand Up @@ -68,28 +64,41 @@ function deserializePackageJSON(path, contents) {

const pjsonPath = optionalFilePath ?? path;

return {
data: {
const data = {
__proto__: null,
...(name != null && { name }),
...(main != null && { main }),
...(type != null && { type }),
};

if (plainExports !== null) {
ObjectDefineProperty(data, 'exports', {
__proto__: null,
configurable: true,
enumerable: true,
get() {
const value = requiresJSONParse(plainExports) ? JSONParse(plainExports) : plainExports;
ObjectDefineProperty(data, 'exports', { __proto__: null, enumerable: true, value });
return value;
},
});
}

if (plainImports !== null) {
ObjectDefineProperty(data, 'imports', {
__proto__: null,
...(name != null && { name }),
...(main != null && { main }),
...(type != null && { type }),
...(plainImports != null && {
// This getters are used to lazily parse the imports and exports fields.
get imports() {
const value = requiresJSONParse(plainImports) ? JSONParse(plainImports) : plainImports;
ObjectDefineProperty(this, 'imports', { __proto__: null, value });
return this.imports;
},
}),
...(plainExports != null && {
get exports() {
const value = requiresJSONParse(plainExports) ? JSONParse(plainExports) : plainExports;
ObjectDefineProperty(this, 'exports', { __proto__: null, value });
return this.exports;
},
}),
},
configurable: true,
enumerable: true,
get() {
const value = requiresJSONParse(plainImports) ? JSONParse(plainImports) : plainImports;
ObjectDefineProperty(data, 'imports', { __proto__: null, enumerable: true, value });
return value;
},
});
}

return {
data,
exists: true,
path: pjsonPath,
};
Expand Down Expand Up @@ -131,43 +140,23 @@ function read(jsonPath, { base, specifier, isESM } = kEmptyObject) {
}

/**
* Given a file path, walk the filesystem upwards until we find its closest parent
* `package.json` file, stopping when:
* 1. we find a `package.json` file;
* 2. we find a path that we do not have permission to read;
* 3. we find a containing `node_modules` directory;
* 4. or, we reach the filesystem root
* @returns {undefined | string}
* A cache mapping a module's path to its parent `package.json` file's path.
* This is used in concert with `deserializedPackageJSONCache` to improve
* the performance of `getNearestParentPackageJSON` when called repeatedly
* on the same module paths.
*/
function findParentPackageJSON(checkPath) {
const enabledPermission = permission.isEnabled();

const rootSeparatorIndex = StringPrototypeIndexOf(checkPath, path.sep);
let separatorIndex;

do {
separatorIndex = StringPrototypeLastIndexOf(checkPath, path.sep);
checkPath = StringPrototypeSlice(checkPath, 0, separatorIndex);
const moduleToParentPackageJSONCache = new SafeMap();

if (enabledPermission && !permission.has('fs.read', checkPath + path.sep)) {
return undefined;
}

if (StringPrototypeEndsWith(checkPath, path.sep + 'node_modules')) {
return undefined;
}

const maybePackageJSONPath = checkPath + path.sep + 'package.json';
const stat = internalFsBinding.internalModuleStat(checkPath + path.sep + 'package.json');

const packageJSONExists = stat === 0;
if (packageJSONExists) {
return maybePackageJSONPath;
}
} while (separatorIndex > rootSeparatorIndex);

return undefined;
}
/**
* A cache mapping the path of a `package.json` file to its
* {@link DeserializedPackageConfig deserialized representation},
* as produced by {@link deserializedPackageJSONCache}. The purpose of this
* cache is to ensure that we always return the same
* {@link DeserializedPackageConfig} instance for a given `package.json`,
* which is necessary to ensure that we don't re-parse `imports` and
* `exports` redundantly.
*/
const deserializedPackageJSONCache = new SafeMap();

/**
* Get the nearest parent package.json file from a given path.
Expand All @@ -176,26 +165,22 @@ function findParentPackageJSON(checkPath) {
* @returns {undefined | DeserializedPackageConfig}
*/
function getNearestParentPackageJSON(checkPath) {
const nearestParentPackageJSON = findParentPackageJSON(checkPath);

if (nearestParentPackageJSON === undefined) {
return undefined;
const parentPackageJSONPath = moduleToParentPackageJSONCache.get(checkPath);
if (parentPackageJSONPath !== undefined) {
return deserializedPackageJSONCache.get(parentPackageJSONPath);
}

if (nearestParentPackageJSONCache.has(nearestParentPackageJSON)) {
return nearestParentPackageJSONCache.get(nearestParentPackageJSON);
}
const result = modulesBinding.getNearestParentPackageJSON(checkPath);
const packageConfig = deserializePackageJSON(checkPath, result);

const result = modulesBinding.readPackageJSON(nearestParentPackageJSON);
moduleToParentPackageJSONCache.set(checkPath, packageConfig.path);

if (result === undefined) {
nearestParentPackageJSONCache.set(checkPath, undefined);
return undefined;
const maybeCachedPackageConfig = deserializedPackageJSONCache.get(packageConfig.path);
if (maybeCachedPackageConfig !== undefined) {
return maybeCachedPackageConfig;
}

const packageConfig = deserializePackageJSON(checkPath, result);
nearestParentPackageJSONCache.set(nearestParentPackageJSON, packageConfig);

deserializedPackageJSONCache.set(packageConfig.path, packageConfig);
return packageConfig;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ function getCallSites(frameCount = 10, options) {

// Using kDefaultMaxCallStackSizeToCapture as reference
validateNumber(frameCount, 'frameCount', 1, 200);
// If options.sourceMaps is true or if sourceMaps are enabled but the option.sourceMaps is not set explictly to false
// If options.sourceMaps is true or if sourceMaps are enabled but the option.sourceMaps is not set explicitly to false
if (options.sourceMap === true || (getOptionValue('--enable-source-maps') && options.sourceMap !== false)) {
return mapCallSite(binding.getCallSites(frameCount));
}
Expand Down
2 changes: 1 addition & 1 deletion src/node_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ BuiltinLoader::BuiltinCategories BuiltinLoader::GetBuiltinCategories() const {
if (prefix.length() > id.length()) {
continue;
}
if (id.find(prefix) == 0 &&
if (id.starts_with(prefix) &&
builtin_categories.can_be_required.count(id) == 0) {
builtin_categories.cannot_be_required.emplace(id);
}
Expand Down
Loading
Loading