From e419afd50c6bc8c6d41188f1affda3a3ef662267 Mon Sep 17 00:00:00 2001 From: Stefan Stojanovic Date: Fri, 3 Apr 2026 12:25:26 +0200 Subject: [PATCH 1/2] module,win: fix long subpath import MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/nodejs/node/issues/62043 PR-URL: https://github.com/nodejs/node/pull/62101 Fixes: https://github.com/nodejs/node/issues/62043 Reviewed-By: Yagiz Nizipli Reviewed-By: René --- src/node_modules.cc | 10 ++++- test/es-module/test-esm-long-path-win.js | 4 +- .../test-module-subpath-import-long-path.js | 40 +++++++++++++++++++ 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-module-subpath-import-long-path.js diff --git a/src/node_modules.cc b/src/node_modules.cc index 7d8e24f915be95..ad1e001ae0b68c 100644 --- a/src/node_modules.cc +++ b/src/node_modules.cc @@ -425,8 +425,16 @@ void BindingData::GetPackageScopeConfig( url::ThrowInvalidURL(realm->env(), resolved.ToStringView(), std::nullopt); return; } + BufferValue file_path_buf(realm->isolate(), + String::NewFromUtf8(realm->isolate(), + file_url->c_str(), + NewStringType::kInternalized, + file_url->size()) + .ToLocalChecked()); + ToNamespacedPath(realm->env(), &file_path_buf); error_context.specifier = resolved.ToString(); - auto package_json = GetPackageJSON(realm, *file_url, &error_context); + auto package_json = + GetPackageJSON(realm, file_path_buf.ToStringView(), &error_context); if (package_json != nullptr) { if constexpr (return_only_type) { Local value; diff --git a/test/es-module/test-esm-long-path-win.js b/test/es-module/test-esm-long-path-win.js index fca22172a85995..d125d341f09202 100644 --- a/test/es-module/test-esm-long-path-win.js +++ b/test/es-module/test-esm-long-path-win.js @@ -60,7 +60,7 @@ describe('long path on Windows', () => { tmpdir.refresh(); fs.mkdirSync(packageDirPath); - fs.writeFileSync(packageJSPath, ''); + fs.writeFileSync(packageJSPath, '{}'); fs.writeFileSync(indexJSPath, ''); const packageJsonUrl = pathToFileURL( @@ -83,7 +83,7 @@ describe('long path on Windows', () => { tmpdir.refresh(); fs.mkdirSync(packageDirPath); - fs.writeFileSync(packageJSPath, ''); + fs.writeFileSync(packageJSPath, '{}'); fs.writeFileSync(indexJSPath, ''); const packageJsonUrl = pathToFileURL( diff --git a/test/parallel/test-module-subpath-import-long-path.js b/test/parallel/test-module-subpath-import-long-path.js new file mode 100644 index 00000000000000..69207746f77062 --- /dev/null +++ b/test/parallel/test-module-subpath-import-long-path.js @@ -0,0 +1,40 @@ +// Regression test for https://github.com/nodejs/node/issues/62043 +'use strict'; + +const common = require('../common'); +if (!common.isWindows) { + common.skip('this test is Windows-specific.'); +} + +const fs = require('fs'); +const { createRequire } = require('module'); +const path = require('path'); +const tmpdir = require('../common/tmpdir'); + +tmpdir.refresh(); + +const TARGET = 260; // Shortest length that used to trigger the bug +const fixedLen = tmpdir.path.length + 2 + 'package.json'.length; +const dirNameLen = Math.max(TARGET - fixedLen, 1); + +const dir = path.join(tmpdir.path, 'a'.repeat(dirNameLen)); +const depDir = path.join(dir, 'node_modules', 'dep'); +const packageJsonPath = path.join(dir, 'package.json'); + +fs.mkdirSync(depDir, { recursive: true }); +fs.writeFileSync( + packageJsonPath, + JSON.stringify({ imports: { '#foo': './foo.mjs' } }), +); +fs.writeFileSync(path.join(dir, 'foo.mjs'), 'export default 1;\n'); +fs.writeFileSync( + path.join(depDir, 'package.json'), + JSON.stringify({ name: 'dep', exports: { '.': './index.mjs' } }), +); +fs.writeFileSync(path.join(depDir, 'index.mjs'), 'export default 1;\n'); + +const req = createRequire(path.join(dir, '_.mjs')); + +// Both resolves should succeed without throwing +req.resolve('dep'); +req.resolve('#foo'); From c02bee3c619da93099b89b3322ed07b86990dff1 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Mon, 30 Mar 2026 09:06:23 -0700 Subject: [PATCH 2/2] meta: require DCO signoff in commit message guidelines Apply suggestion from @jasnell PR-URL: https://github.com/nodejs/node/pull/62510 Refs: https://github.com/nodejs/core-validate-commit/pull/141 Reviewed-By: Antoine du Hamel Reviewed-By: Chengzhong Wu Reviewed-By: Ruy Adorno Reviewed-By: Filip Skokan Reviewed-By: Marco Ippolito Reviewed-By: Trivikram Kamat --- doc/contributing/pull-requests.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/contributing/pull-requests.md b/doc/contributing/pull-requests.md index b2556577536791..9118374a95319f 100644 --- a/doc/contributing/pull-requests.md +++ b/doc/contributing/pull-requests.md @@ -199,6 +199,14 @@ A good commit message should describe what changed and why. contain an explanation about the reason of the breaking change, which situation would trigger the breaking change, and what is the exact change. +6. Your commit must contain the `Signed-off-by` line with your name and email + address as an acknowledgement that you agree to the [Developer Certificate of Origin][]. + Bot generated commits are exempt from this requirement. If a commit has + multiple authors, the `Signed-off-by` line should be added for each author; + and at least one should match the author information in the commit metadata. + This rule does not apply to dependency updates (e.g. cherry-picks), release + commits, or backport commits. + Sample complete commit message: ```text @@ -210,6 +218,7 @@ less. Fixes: https://github.com/nodejs/node/issues/1337 Refs: https://eslint.org/docs/rules/space-in-parens.html +Signed-off-by: J. Random User ``` If you are new to contributing to Node.js, please try to do your best at @@ -594,6 +603,7 @@ More than one subsystem may be valid for any particular issue or pull request. [Building guide]: ../../BUILDING.md [CI (Continuous Integration) test run]: #continuous-integration-testing [Code of Conduct]: https://github.com/nodejs/admin/blob/HEAD/CODE_OF_CONDUCT.md +[Developer Certificate of Origin]: ../../CONTRIBUTING.md#developers-certificate-of-origin-11 [Onboarding guide]: ../../onboarding.md [approved]: #getting-approvals-for-your-pull-request [benchmark results]: writing-and-running-benchmarks.md