Fix: Build clients race condition - #126
Merged
Merged
Conversation
Previously, the client build process deleted the old contract code before building and installing the new ones. While running in watch mode concurrently with the frontend dev server, this caused a hot-reload which would throw an error since app code is importing contracts that don't exist until rebuilt. This change builds and installs the contracts in a temp directory then replaces the contract code at once, ensuring only one hot-reload and no broken imports. This has the added benefit of being able to use the old contract code as a backup if the build/install process fails for any reason.
BlaineHeffron
suggested changes
Jul 2, 2025
BlaineHeffron
left a comment
Contributor
There was a problem hiding this comment.
Nice work, I think this a good solution. You shouldn't need to copy the contract template to the temporary directory since that lives in a separate place from the typescript bindings. I would just remove that (and that should remove the need for the write_contract_template_to_dir refactor).
willemneal
requested changes
Jul 7, 2025
BlaineHeffron
approved these changes
Jul 7, 2025
BlaineHeffron
suggested changes
Jul 7, 2025
BlaineHeffron
left a comment
Contributor
There was a problem hiding this comment.
When I run build clients I get an error: Error: Directory not empty (os error 39)
It appears to be happening during the rename line 357. Might need to supply options to rewrite or use a different fn.
BlaineHeffron
suggested changes
Jul 8, 2025
willemneal
approved these changes
Jul 8, 2025
willemneal
enabled auto-merge (squash)
July 8, 2025 17:15
BlaineHeffron
approved these changes
Jul 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the client build process deleted the old contract code before building and installing the new ones. While running in watch mode concurrently with the frontend dev server, this caused a hot-reload which would throw an error since app code is importing contracts that don't exist until rebuilt.
This change builds and installs the contracts in a temp directory then replaces the contract code at once, ensuring only one hot-reload and no broken imports. This has the added benefit of being able to use the old contract code as a backup if the build/install process fails for any reason.