Skip to content

PiT 24.4: when migrating a project to 24.4 modifications to tsconfig.json and types.d.ts should throw once #18984

Closed

Description

@manolo

Description of the bug

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

latest-lit-top.zip

Versions

  • Vaadin / Flow version: 24.4.0.alpha15

Activity

  1. Legioth commented on Mar 19, 2024

    @Legioth
    Member

    It should throw just once

    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.

  2. Legioth commented on Mar 19, 2024

    @Legioth
    Member

    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.

  3. cromoteca commented on Mar 19, 2024

    @cromoteca
    Contributor

    This could be solved by using createTempFile(String prefix, String suffix, File directory) to create the backup file.

  4. moved this to 🔖 High Priority (P1) in Vaadin Flow bugs & maintenanceon Mar 19, 2024
  5. moved this from 🪵Product backlog to 🟢Ready to Go in Vaadin Flow | Hilla | Kits ongoing workon Mar 19, 2024
  6. self-assigned this
    on Mar 19, 2024
  7. moved this from 🟢Ready to Go to ⚒️ In progress in Vaadin Flow | Hilla | Kits ongoing workon Mar 19, 2024
  8. mshabarov commented on Mar 19, 2024

    @mshabarov
    Contributor

    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.

  9. added 2 commits that reference this issue on Mar 19, 2024
    6e3fb1e
    d2ed1c1
  10. added a commit that references this issue on Mar 20, 2024
    867825c
  11. moved this from 🔖 High Priority (P1) to ✅ Closed in Vaadin Flow bugs & maintenanceon Mar 20, 2024
  12. vaadin-bot commented on Mar 20, 2024

    @vaadin-bot
    Collaborator

    This ticket/PR has been released with Vaadin 24.4.0.alpha16 and is also targeting the upcoming stable 24.4.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions