Skip to content

fix: deleting an island wedges the dev server#3883

Open
aiibe wants to merge 1 commit into
freshframework:mainfrom
aiibe:fix/island-delete-wedges-dev-server
Open

fix: deleting an island wedges the dev server#3883
aiibe wants to merge 1 commit into
freshframework:mainfrom
aiibe:fix/island-delete-wedges-dev-server

Conversation

@aiibe

@aiibe aiibe commented Jun 26, 2026

Copy link
Copy Markdown

The Problem

Whenever you deleted a file from the islands/ folder while running deno task dev, the whole app would crash with a permanent HTTP 500 error until you completely restarted the server. Because Fresh auto-discovers everything in that folder, this happened even if the island you deleted wasn't actually being used anywhere in the app.

What was happening?

There were basically two gaps that combined to wedge the server:

  1. The file watcher was missing things: It was only looking for changes in the routes/ directory, so deleting an island didn't actually tell the server snapshot that it needed to rebuild.
  2. The internal map was hoarding data: The server-snapshot plugin only ever added islands to its internal list. It never cleared out deleted ones. So, the deleted island stuck around as a dead static import, which ultimately choked the server on every subsequent request.

The Fix

I made two changes that work together to solve this:

  • Actually watch the islands: I expanded the file watcher so it now tracks both routes and islands. Now, adding or deleting an island instantly forces the snapshot to rebuild.
  • Start fresh on reload: I updated the load handler to completely clear out and rebuild the island map from scratch on every reload, rather than just adding to it. I also threw in a quick cache to make sure the generated island names stay stable and don't drift between rebuilds.

Testing

I added a new test (dev_server_test.ts) that specifically mimics this bug. It loads up a page, deletes an unused island, and verifies that the server successfully recovers and keeps happily returning 200s instead of crashing.

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 this pull request may close these issues.

1 participant