Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions src/node_modules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,18 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
return &cache_entry->second;
}

if (!binding_data->missing_package_configs_.contains(path.data())) {
return nullptr;
}

PackageConfig package_config{};
package_config.file_path = path;
// No need to exclude BOM since simdjson will skip it.
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
// Cache the failed read so that other queries in the same folder don't
// keep probing the file system
binding_data->missing_package_configs_.insert(
std::string(path));
return nullptr;
}
// In some systems, std::string is annotated to generate an
Expand Down
1 change: 1 addition & 0 deletions src/node_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class BindingData : public SnapshotableObject {

private:
std::unordered_map<std::string, PackageConfig> package_configs_;
std::unordered_set<std::string> missing_package_configs_;
simdjson::ondemand::parser json_parser;
// returns null on error
static const PackageConfig* GetPackageJSON(
Expand Down
Loading