Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
fixup! src: move package resolver to c++
  • Loading branch information
joyeecheung committed Jan 15, 2025
commit 7c940005374d4915662149d8478c940413cb248b
20 changes: 20 additions & 0 deletions src/node_modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(

PackageConfig package_config{};
package_config.file_path = path;

#ifdef _AIX
// On AIX, the file read can still succeed even if it's a directory.
// For backporting https://github.com/nodejs/node/pull/50322 to v20.x,
// add the special case back and return early to notify the JS land
// and let it treat it as if the package.json does not exist.
// See https://github.com/libuv/libuv/pull/2025 and
// https://github.com/nodejs/node/pull/48477#issuecomment-1604586650
uv_fs_t req;
int rc = uv_fs_stat(nullptr, &req, path.data(), nullptr);
if (rc == 0) {
const uv_stat_t* const s = static_cast<const uv_stat_t*>(req.ptr);
bool is_dir = ((s->st_mode & S_IFMT) == S_IFDIR);
uv_fs_req_cleanup(&req);
if (is_dir) {
return nullptr;
}
}
#endif

// No need to exclude BOM since simdjson will skip it.
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
return nullptr;
Expand Down