starkware-libs / cairo

Cairo is the first Turing-complete language for creating provable programs for general computation.
Apache License 2.0
1.6k stars 495 forks source link

Project loading should happen asynchronously #6128

Open mkaput opened 3 months ago

mkaput commented 3 months ago

Primarily, calling scarb metadata should be an asynchronous process that does not block project model updates like it does currently.

Requirements

piotmag769 commented 15 hours ago

Gracefully deal with projects which loading fails. In such cases, avoid clearing relevant salsa inputs to preserve as much cached queries as possible. For example, a syntax error in the manifest file (this will make scarb metadata fail) shouldn't cause wiping of all analysis state

@mkaput this is no longer the case, no? We just try to init unmanaged corelib in case metadata fails now

mkaput commented 6 hours ago

This is more about recovering from breakage when metadata did succeed already. Take a following scenario as an example:

  1. You open OpenZeppelin/cairo-contracts
  2. It analyses successfully.
  3. You open Scarb.toml and make a syntax error.
  4. scarb metadata will now refresh and it will fail

I don't want to lose all the analysis information due to this problem because it is easily recoverable: if we know something about the code already, and this information is reliable, let's persist that information instead of wiping it.

Mind that with detect_crate_for this is already working as intended, but it's a consequence of luck rather than deliberate engineering.