Skip to content

Conversation

kayagokalp
Copy link
Member

Description

closes #7376 and TOOL-681

Problem: When registry package fetching fails, the created directory remains in ~/.forc/registry/, causing subsequent builds to fail because forc assumes the directory contains a valid package.

To mitigate this:

  • Moved directory creation: Directory creation now happens after validating the package exists in the registry index.
  • Added cleanup guard: Used scopeguard::guard to ensure automatic cleanup if fetch fails.
  • Implemented proper error handling: On successful fetch, the guard is defused; on failure, the directory is automatically removed.

Testing

  • test_fetch_directory_cleanup_on_failure validates that failed fetches properly clean up directories

@kayagokalp kayagokalp self-assigned this Sep 5, 2025
@kayagokalp kayagokalp marked this pull request as ready for review September 5, 2025 20:21
@kayagokalp kayagokalp requested review from a team as code owners September 5, 2025 20:21
@kayagokalp kayagokalp enabled auto-merge (squash) September 5, 2025 20:22
Copy link

codspeed-hq bot commented Sep 5, 2025

CodSpeed Performance Report

Merging #7377 will not alter performance

Comparing kayagokalp/tool-681 (6de83c0) with master (6981d3d)

Summary

✅ 25 untouched benchmarks

@JoshuaBatty JoshuaBatty requested a review from a team September 8, 2025 03:31
@JoshuaBatty JoshuaBatty added the forc-pkg Everything related to the `forc-pkg` crate. label Sep 9, 2025
@kayagokalp kayagokalp merged commit b552ba1 into master Sep 10, 2025
41 checks passed
@kayagokalp kayagokalp deleted the kayagokalp/tool-681 branch September 10, 2025 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forc-pkg Everything related to the `forc-pkg` crate.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better handling for failed package fetches in forc-pkg
3 participants