-
Notifications
You must be signed in to change notification settings - Fork 1
Treat opendir
failures as empty directories
#186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 12e9c20 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
opendir
failures as empty directoriesopendir
failures as empty directories
"react-native-node-api", // The host package itself | ||
"react-native", // React Native core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two known packages known not to have Node-API prebuilds which we want to link in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the Node-API module discovery to treat directory read failures as empty directories and completely exclude the host and React Native packages.
- Wraps
fs.promises.opendir
in atry/catch
to skip over unreadable directories. - Removes the path-based exclusion for
react-native-node-api
and adds a package-name exclusion list. - Filters out
react-native-node-api
andreact-native
infindNodeApiModulePathsByDependency
and adds a test for the unreadable-directory case.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
packages/host/src/node/path-utils.ts | Wrap opendir in try/catch , remove path exclude, add package-name exclude. |
packages/host/src/node/path-utils.test.ts | Adjust existing test and add new test for unreadable directories. |
.changeset/stale-coins-drop.md | Add changeset entry summarizing the fix. |
Comments suppressed due to low confidence (2)
packages/host/src/node/path-utils.ts:354
- [nitpick] The comment refers to 'patterns' but the constant is a list of package names. Update the doc to clearly state these are package names being excluded.
* Default patterns to use when excluding package names from the search for Node-API modules.
packages/host/src/node/path-utils.ts:385
- There’s no test verifying that 'react-native-node-api' and 'react-native' are actually excluded. Add a test case to cover the
excludePackages
behavior infindNodeApiModulePathsByDependency
.
.filter(([name]) => !excludePackages.includes(name))
packages/host/src/node/path-utils.ts
Outdated
} catch { | ||
// Intentionally left empty: if the directory cannot be read, we skip it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Catching all errors here may mask unexpected issues (e.g., permission vs. path-not-found). Consider narrowing this to specific filesystem errors like ENOENT or EACCES to avoid hiding genuine failures.
} catch { | |
// Intentionally left empty: if the directory cannot be read, we skip it | |
} catch (error: any) { | |
if (error.code === "ENOENT" || error.code === "EACCES") { | |
// Skip the directory if it does not exist or access is denied | |
} else { | |
throw error; // Re-throw unexpected errors | |
} |
Copilot uses AI. Check for mistakes.
f5af8fd
to
12e9c20
Compare
Merging this PR fixes #185 by introducing a few changes to the implementation used when looking for Node-API modules on the filesystem:
opendir
failures as empty directories.react-native-node-api
andreact-native
packages completely.