Skip to content
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

migration builder causes stack overflow when run from workspace dir #68

Open
johnny-smitherson opened this issue Dec 27, 2024 · 0 comments · May be fixed by #67
Open

migration builder causes stack overflow when run from workspace dir #68

johnny-smitherson opened this issue Dec 27, 2024 · 0 comments · May be fixed by #67

Comments

@johnny-smitherson
Copy link

johnny-smitherson commented Dec 27, 2024

The error thread 'main' has overflowed its stack shows on windows when trying to programatically run migrations:

  1. The bin crate is not part of a workspace (it's a top level crate with no workspace) --> stack overflow
  2. The bin crate is part of a workspace, but the cargo run --bin X command is ran from the workspace directory ---> stack overflow
  3. The bin crate is part of a workspace, the directory was changed to the sub-crate ---> no stack overflow

After some debugging I found the overflow happens in MigrationBuilder::build(), CodeSchema::get_models_from_code() because WalkDir() hits the decently-sized target/ directory in the workspace.

The command should not scan any target/ directory, or any directory outside src/.

Adding .max_depth(4) to the WalkDir removes the error (but limits arrangement).

Added commit on top of other PR: fac8b40

It now avoids scanning target/, collects all src/, then iterates those src/ only.

The migrate commands might still be slow if you happen to have a lot of data in a folder in the workspace or crate root. Might be useful to automatically ignore files listed in .gitignore, as is the case here.

Even better would be to parse the workspace Cargo.toml structure to get the list of members, and only scan those.

@johnny-smitherson johnny-smitherson linked a pull request Dec 27, 2024 that will close this issue
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 a pull request may close this issue.

1 participant