Skip to content

[extension_discovery] reliablyRename always throws after a successful rename on Windows #2681

Closed

Description

@hkarmoush

_attempt in lib/src/io.dart:

while (true) {
  try {
    await fn();
  } on FileSystemException catch (e) {
    ...
  }
}

On Windows there's no return/break after a successful fn(), so the loop runs fn() again. For rename the second call fails because the source no longer exists (errno 2, not 5 or 32) and is rethrown. I ran the same loop with a plain file rename on macOS to check the logic: the rename succeeds, then the call throws PathNotFoundException.

In registry.dart this exception is swallowed (on IOException), so the cache file does get written, but _ensureReadme right after reliablyRename is skipped, so the README is never written to the cache dir on Windows. The non-Windows branch correctly returns the result.

Fix is to return await fn(); inside the try.

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

Metadata

Metadata

Assignees

Labels

type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions