You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PiT 24.4: when migrating a project to 24.4 modifications to tsconfig.json and types.d.ts should throw once #18984
When frontend configuration files require updating, Flow does not perform these updates in a batch. Instead, it executes separate modifications and throws errors, necessitating the user to run the application multiple times after the migration.
NOTE: it makes several projects run with the PiT script fail because it only considers one extra run
Expected behavior
It should throw just once
Minimal reproducible example
The attached project is a 24.3 project with the needed modifications to run in 24.4, but types.d.ts, tsconfig.json and package.json have not been modified.
Unzip the project and run mvn, you need to run 3 times
If I understand it correctly, what happens is that Flow creates a backup of the file in the project and then puts a new file with the default content in its place. The throwing happens only if the backup cannot be created because an old backup is in the way.
It might be enough to just clarify the error to inform that it's caused by leaving old backups behind. A more laborious approach would be to resolve the naming conflict by optionally adding a unique postfix to the name of the new backup file.
The throwing happens only if the backup cannot be created because an old backup is in the way.
Back-ups are not created for tsconfig.json (at least I couldn't find back-up logic in TaskGenerateTsConfig).
Sounds to me like tsconfig.json and types.d.ts auto-update feature needs more unification and better DX.
Here is a draft of requirement that we might want to apply to both types.d.ts and tsconfig.json to address this issue:
Flow creates back-up files always when it want to modify the content, for tsconfig.json at least I couldn't find back-up logic in TaskGenerateTsConfig
File auto-update creates a back-up file in a unified format with a timestamp or other unique postfix that avoid copy conflicts if file already exists.
Flow doesn't throw nor doesn't it log a warning if files have one of the default contents from known templates.
Flow collects all the warning messages to user during build time and only shows them once in the end. This addresses the issue above and also should address an issue when you got tons of exceptions in the log, preventing you even read the message, because any page refresh request triggers this exception.
Flow doesn't log a stacktraces, only messages/banners.
Also, probably it's better to log a warning, rather than throw, but I have no strong opinion regarding it.
Activity
Legioth commentedon Mar 19, 2024
My expectation is that it wouldn't throw at all but instead just update everything and then work without requiring the user to re-run anything.
Legioth commentedon Mar 19, 2024
If I understand it correctly, what happens is that Flow creates a backup of the file in the project and then puts a new file with the default content in its place. The throwing happens only if the backup cannot be created because an old backup is in the way.
It might be enough to just clarify the error to inform that it's caused by leaving old backups behind. A more laborious approach would be to resolve the naming conflict by optionally adding a unique postfix to the name of the new backup file.
cromoteca commentedon Mar 19, 2024
This could be solved by using createTempFile(String prefix, String suffix, File directory) to create the backup file.
mshabarov commentedon Mar 19, 2024
Back-ups are not created for
tsconfig.json(at least I couldn't find back-up logic in TaskGenerateTsConfig).Sounds to me like
tsconfig.jsonandtypes.d.tsauto-update feature needs more unification and better DX.Here is a draft of requirement that we might want to apply to both
types.d.tsandtsconfig.jsonto address this issue:tsconfig.jsonat least I couldn't find back-up logic inTaskGenerateTsConfigAlso, probably it's better to log a warning, rather than throw, but I have no strong opinion regarding it.
Fix: update file and log message
Fix: update tsconfig and log message
Fix: update tsconfig and log message (#18987)
vaadin-bot commentedon Mar 20, 2024
This ticket/PR has been released with Vaadin 24.4.0.alpha16 and is also targeting the upcoming stable 24.4.0 version.