Skip to content

removeEmptyDirs reports a directory it cannot read, then throws on it anyway #71

Description

@shellicar

Reading the output directory is guarded and the failure is reported, but the check for whether anything is left in it is not, so an unreadable directory surfaces as a throw regardless.

const entries = await getEntries(dir, logger);   // catches, logs, returns []
// ...
const remaining = await readdir(dir);            // same directory, unguarded

The guard's shape says the failure is handled. It isn't: it's reported, then hit again a few lines later, and the second read is what the caller sees.

The decision is which of the two the guard was meant to be. Either the failure is survivable, in which case the second read needs the same treatment, or it isn't, in which case the guard should go and let it surface once.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    internalNo user-facing effect — refactoring, internal correctness, unreachable code pathspkg: build-cleanBuild plugin — cleans unused output files

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions