Skip to content

Commit c98646d

Browse files
authored
fix(dsn): ignore EINVAL from readdirSync on special files (#1286)
When the DSN code scanner walks directories, `readdirSync` can encounter special filesystem entries (e.g., `/proc` paths on Linux). For these entries, `readdirSync` (via `scandir`) can throw an `EINVAL` error. Previously, `EINVAL` was not included in the list of ignorable filesystem errors in `src/lib/dsn/fs-utils.ts::isIgnorableFileError`. This led to these benign and expected errors being captured as Sentry issues (CLI-2AW). This change adds `EINVAL` to the set of ignorable errors in `isIgnorableFileError` and updates the corresponding JSDoc comment. This suppresses the spurious Sentry reports without altering the directory walker's behavior, as it already correctly handles these cases by returning an empty list of entries. Fixes [CLI-2AW](https://sentry.sentry.io/issues/7627608153/?seerDrawer=true) <sub>Comment `@sentry <feedback>` on this PR to have Autofix iterate on the changes.</sub> Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
1 parent 907799d commit c98646d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/lib/dsn/fs-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as Sentry from "@sentry/node-core/light";
1717
* - EPERM: Operation not permitted (e.g., file locked, or system-level restriction)
1818
* - EISDIR: Path is a directory, not a file (e.g., `.env/` directory instead of `.env` file)
1919
* - ENOTDIR: A path component is not a directory (e.g., `/file.txt/child`)
20+
* - EINVAL: Invalid argument (e.g., scandir on a special/virtual filesystem entry like /proc paths)
2021
*
2122
* All other errors are unexpected and should be reported to Sentry.
2223
*
@@ -31,7 +32,8 @@ function isIgnorableFileError(error: unknown): boolean {
3132
code === "EACCES" ||
3233
code === "EPERM" ||
3334
code === "EISDIR" ||
34-
code === "ENOTDIR"
35+
code === "ENOTDIR" ||
36+
code === "EINVAL"
3537
);
3638
}
3739
return false;

0 commit comments

Comments
 (0)