-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(local) better cleanup during start and shutdown #130
Conversation
throw new Error( | ||
`unexpected error during shutdown: ${err.message as string}` | ||
); | ||
} finally { | ||
this.#_cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the potentially confusing finally
block.
// we allow passing an optional directory to clean in case the user wants | ||
// to cleanup before starting | ||
if (typeof validatorDir !== "string") { | ||
validatorDir = this.validatorDir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We had been cleaning up before starting the Validator, and the directory where the validator backups are stored can't be determined by the instance until after starting.
To enable pre-start cleanup, we now allow a directory value to be optionally passed in.
shell.rm("-rf", resolve(this.validatorDir, "backups")); | ||
|
||
const dbFiles = [ | ||
resolve(this.validatorDir, "database.db"), | ||
resolve(this.validatorDir, "database.db-shm"), | ||
resolve(this.validatorDir, "database.db-wal"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These -shm
and -wal
endings were not getting removed.
e85140e
to
9638aca
Compare
9638aca
to
ac21030
Compare
@@ -394,6 +395,7 @@ class LocalTableland { | |||
|
|||
this.validator.process.on("close", () => resolve()); | |||
this.validator.shutdown(); | |||
this.validator.cleanup(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix for the issue @dtbuchholz outlines here: https://gist.github.com/dtbuchholz/ff5a8c261ff282bb72476bc1ad02f328
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, nice! and thanks for the details on the gist...I can use that as a reference for new docs on this feature
Overview
As seen here, https://gist.github.com/dtbuchholz/ff5a8c261ff282bb72476bc1ad02f328#file-e2e-test-ts, the hardhat snapshotting was not working because the database backup was not being reset when the Validator was reset.
Details
This PR fixes the reset procedure to allow chain snapshotting, and also include better cleanup logic for database backup files.