Skip to content

Gleam language server rebuilds trigger constant page reloads #154

@alixinne

Description

@alixinne

Hello! New to Gleam & Lustre so I hope it's not something wrong with my setup, but I have noticed the following issue while following the Lustre tutorial.

When running a project based on the Full stack applications with the following commands:

# In client/
gleam run -m lustre/dev start

# In server/
gleam run

Editing a file in Neovim with the Gleam LS running results in the browser hot-reloading the page on every keystroke. Here's the browser console log after typing 3 characters in the src/client.gleam file:

Opening http://localhost:1312/
[lustre] Connection lost, attempting to reconnect... server-hot-reload.js:92:13
[user-agent leaked] using async method http://localhost:1312/ isolated.js:102:15
[lustre] Connected to development server server-hot-reload.js:42:13

[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css 2 server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17

Disabling the language server stops the issue occurring on every keystroke, but it still seems that writing the file triggers multiple reloads, followed by a full page reload:

Opening http://localhost:1312/
[lustre] Connection lost, attempting to reconnect... server-hot-reload.js:92:13
[user-agent leaked] using async method http://localhost:1312/ isolated.js:102:15
[lustre] Connected to development server server-hot-reload.js:42:13

[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css 2 server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
[lustre] Asset updated client.css server-hot-reload.js:66:17
Opening http://localhost:1312/
[lustre] Connection lost, attempting to reconnect... server-hot-reload.js:92:13
[user-agent leaked] using async method http://localhost:1312/ isolated.js:102:15
[lustre] Page reloaded by hot reload server-hot-reload.js:11:13
[lustre] Connected to development server server-hot-reload.js:42:13

The language server seems to be rebuilding on every keystroke and writing to client/build as evidenced by inotifywait:

$ inotifywait --recursive -m client -e close_write
Setting up watches.  Beware: since -r was given, this may take a while!
Watches established.
client/build/ CLOSE_WRITE,CLOSE gleam-lsp-javascript.lock
client/build/ CLOSE_WRITE,CLOSE gleam-lsp-javascript.lock
client/build/ CLOSE_WRITE,CLOSE gleam-lsp-javascript.lock
[ ... continues as I type more, without saving the file ... ]

I feel like the 50ms debouncing added in 925db00 might be too short to be effective in grouping all fs events together?

System info, just in case:

  • system: "x86_64-linux"
  • host os: Linux 6.18.4, NixOS, 26.05 (Yarara), 26.05.20260111.ffbc9f8
  • gleam: 1.14.0
  • lustre: 5.5.2
  • lustre_dev_tools: 2.3.4
  • bun: 1.3.5
  • tailwindcss: 4.1.18

And gleam.toml section for the dev tools:

[tools.lustre.bin]
bun = "system"
tailwindcss = "system"

[tools.lustre.build]
minify = true
outdir = "../server/priv/static"

[tools.lustre.dev]
host = "0.0.0.0"
port = 1312
proxy = { from = "/api", to = "http://localhost:1313/api" }
watch_mode = "events"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions