Skip to content

Fix ContentModified errors in info view while typing#679

Merged
mhuisi merged 1 commit intoleanprover:masterfrom
brandondong:ContentModified_error
Oct 13, 2025
Merged

Fix ContentModified errors in info view while typing#679
mhuisi merged 1 commit intoleanprover:masterfrom
brandondong:ContentModified_error

Conversation

@brandondong
Copy link
Contributor

Issue:

While typing up longer proofs, I frequently see an error in the info view: Error updating: Error fetching goals: Rpc error: ContentModified: File changed. (maybe it happens to me frequently because my computer is on the older side).

It's super annoying because all the usual premise/goal info in the view is temporarily cleared to display the error and I need to wait for Lean to finish its processing before the info appears again.

Here's a video with me making contrived edits to demonstrate the issue:
https://github.com/user-attachments/assets/a077a113-7821-44bc-a307-40c0b3d37bb4

I checked the code and there should already be logic in place to not clear the info view for this particular rpc error:
image

Root cause:

Debugging, the original rpc error is being thrown from Widget_getWidgets
image

However, it's being handled by discardMethodNotFound which for this type of error, will call mapRpcError. This will convert the original rpc error with its code information into an opaque Error type. This bypasses the aforementioned RpcErrorCode.ContentModified check and we end up resolving with the error string incorrectly.

Fix:

  • Update discardMethodNotFound to just rethrow the original exception when it's not the special case of RpcErrorCode.MethodNotFound which it's specifically written to handle.
  • This allows the info view fetch error handling code to operate on the original rpc exception. discardMethodNotFound is not used anywhere else.

// to the RPC sessions. Try again.
setUpdaterTick(t => t + 1)
reject('retry')
return
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before debugging, my first guess was the bug was due to a lack of return here. It will call reject but then there's nothing stopping the code from continuing further down and calling resolve.

It turns out Promise's just return the value of the first resolve/reject that you call if you decide to call more than one, TIL. Anyways, I just added an explicit return here. Not doing so will result in purely wasted work executing the logic below only for Promise to take the first result.

@mhuisi
Copy link
Collaborator

mhuisi commented Oct 13, 2025

Thanks! Good diagnosis :-)

@mhuisi mhuisi merged commit 55ee372 into leanprover:master Oct 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants