Skip to content

fix: prevent deletion of dev-server generated files by cleanup task#24677

Closed
sissbruecker wants to merge 1 commit into
mainfrom
fix/prevent-vite-devmode-deletion-by-cleanup
Closed

fix: prevent deletion of dev-server generated files by cleanup task#24677
sissbruecker wants to merge 1 commit into
mainfrom
fix/prevent-vite-devmode-deletion-by-cleanup

Conversation

@sissbruecker

Copy link
Copy Markdown
Contributor

Description

When starting an app with vaadin.frontend.hotdeploy enabled, and then running mvn compile afterwards, it deletes frontend files that are required for the app to function. The worst offender is deleting vite-devmode.ts, which, due to a JS listener that Vite injects into the HTML, causes the app to reload infinitely, as the file can never be loaded.

The files are removed because compile also runs flow:prepare-frontend, which attempts to remove unused frontend files. It does make some exceptions, however it doesn't consider files that are required for hot deploy mode specifically.

This change adds some more exclusions that I had to add to get the frontend working again: vite-devmode.ts, index.tsx, vaadin-react.tsx, layouts.json, ReactAdapter.tsx

Related to #24108

Type of change

  • Bugfix

TaskRemoveOldFrontendGeneratedFiles deletes files in the frontend
generated folder that are not recognized as known generated files. Files
generated only by the dev server with hot deploy (index.tsx,
vaadin-react.tsx, layouts.json, flow/ReactAdapter.tsx, vite-devmode.ts)
are not tracked when a standalone prepare-frontend runs without the index
and React generation tasks, so they get deleted. The running app still
references these files, which breaks the page: missing vite-devmode.ts
triggers an infinite reload loop through its onerror reload handler, and
missing index.tsx/vaadin-react.tsx break the vaadin.ts import graph and
show a Vite error.

Add these files to the known files list, extending the earlier fix for
app-shell-imports.

Related to #24108

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it feels like the exclusion approach is not very solid, so maybe we should look for a more appropriate fix.

If it helps, the issue can be reproduced in flow-components:

  • Start a Jetty server in hot deploy mode mvn package jetty:run -Dvaadin.pnpm.enable -Dvaadin.frontend.hotdeploy=true -am -B -q -DskipTests -pl vaadin-button-flow-parent/vaadin-button-flow-integration-tests
  • Run the frontend prepare goal: mvn flow:prepare-frontend -pl vaadin-button-flow-parent/vaadin-button-flow-integration-tests
  • Open the app in the browser, observe that the page reloads infinitely

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

Test Results

 1 451 files   -  1   1 451 suites   - 1   1h 25m 45s ⏱️ - 1m 2s
10 249 tests  - 11  10 181 ✅  - 11  68 💤 ±0  0 ❌ ±0 
10 721 runs   - 11  10 652 ✅  - 11  69 💤 ±0  0 ❌ ±0 

Results for commit 5b3e70b. ± Comparison against base commit 0bfcdeb.

@Artur-

Artur- commented Jun 18, 2026

Copy link
Copy Markdown
Member

#24679 would be an alternative approach for this that wouldn't require listing all files

@sissbruecker

Copy link
Copy Markdown
Contributor Author

That looks like a saner approach so let's go with that.

@sissbruecker sissbruecker deleted the fix/prevent-vite-devmode-deletion-by-cleanup branch June 18, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants