-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(core): tree should not be changed after committed to disk in migrations #17071
fix(core): tree should not be changed after committed to disk in migrations #17071
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
☁️ Nx Cloud ReportCI is running/has finished running commands for commit c0a55f9. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this branch ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
7627de3
to
bcc841f
Compare
bcc841f
to
fef4af1
Compare
Maybe it would be worth adding eslint rules to catch these improperly-handled promises as well? :)
|
fef4af1
to
cab2ffa
Compare
cab2ffa
to
54700e4
Compare
packages/nx/src/generators/tree.ts
Outdated
@@ -360,14 +364,20 @@ export class FsTree implements Tree { | |||
// TODO (v17): Remove condition | |||
if (gt(nxVersion, '17.0.0')) { | |||
throw new Error( | |||
'The tree has already been committed to disk. It can no longer be modified. Do not modify the tree during a GeneratorCallback and ensure that Promises have resolved before the generator returns or resolves.' | |||
`The tree has already been committed to disk ${ |
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.
File changes have already been written to disk...
Go ahead and make this an error.
54700e4
to
f536835
Compare
packages/nx/src/generators/tree.ts
Outdated
title: `File changes have already been written to disk. Further changes were attempted ${ | ||
this.logOperationId ? `while running ${this.logOperationId}.` : '.' | ||
}`, |
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.
nit:
title: `File changes have already been written to disk. Further changes were attempted ${ | |
this.logOperationId ? `while running ${this.logOperationId}.` : '.' | |
}`, | |
title: `File changes have already been written to disk. Further changes were attempted${ | |
this.logOperationId ? ` while running ${this.logOperationId}.` : '.' | |
}`, |
packages/nx/src/generators/tree.ts
Outdated
this.logOperationId ? `while running ${this.logOperationId}.` : '.' | ||
}`, | ||
bodyLines: [ | ||
'It can no longer be modified. This commonly happens when a generator attempts to make further ', |
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.
Now there's no previous mention of the tree. I think the It
here lacks context about what it's referring to.
'It can no longer be modified. This commonly happens when a generator attempts to make further ', | |
'The tree can no longer be modified. This commonly happens when a generator attempts to make further ', |
packages/nx/src/generators/tree.ts
Outdated
'It can no longer be modified. This commonly happens when a generator attempts to make further ', | ||
'changes in its callback, or an asynchronous operation is still running after the generator completes.', |
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.
Splitting a single sentence into multiple lines can make the sentence split weirdly in the terminal when the terminal is narrower than the parts. I think it's better not to break a sentence into various lines.
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.
Sure, that makes sense.
f536835
to
c0a55f9
Compare
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
Current Behavior
It is hard to debug when a migration writes to the tree after it has been committed. This only occurs when an async statement is not awaited or similar issues with promises, and the migration is assumed to be complete. As such, the warning that you get is in the middle of other migrations and its hard to track down which migration actually has the issue.
This changes how the logs are created to include more context to make the experience nicer.
Expected Behavior
"Changed after committed" warnings include the reason the tree was created.
Related Issue(s)
Fixes #17064