Skip to content

fix(loader-client,loader-server): the watchers throttle on the first event instead of debouncing #136

Open

Description

@Exeloo

Which app is this bug report for?

other

Issue description

Applies to client and server.

Both watchers act on the first fs event and ignore the following ones for 100 ms (client watch.ts#L29-L45, server watch.ts#L4-L11).

  • A build that writes its files over more than 100 ms triggers a reload or restart in the middle of the build: the page can fetch the manifest of a half-written build, and the changes inside the window are dropped.
  • The client's two watchers (client dir and --watch-server-dir) share one lastCall, so a server change less than 100 ms after a client change is lost.
  • The docs describe a debounce ("Changes closer than 100 ms count as one", client.mdx#L51, server.mdx#L33), not this behavior.

Found by reading the code path (not reproduced).

Expected: one reload or restart after the last change of a burst.

Suggested fix: a trailing debounce (reset a setTimeout on each event), one timer per watched folder.

Found during a read-only audit of main @ 044c766 (2026-11-11).

Code sample

let lastCall = Date.now();
const onClientWatch = () => {
  if (lastCall + 100 > Date.now()) return; // drops the rest of the burst
  lastCall = Date.now();
  server.publish("watch", "update");       // fires on the first event
};

Versions

  • @nanoforge-dev/loader-client / @nanoforge-dev/loader-server / @nanoforge-dev/loader-website 1.7.0 (main @ 044c766)
  • Bun 1.3.14
  • Linux x86_64

Issue priority

Medium (should be fixed soon)

I have tested this issue on a development release

044c766

Activity

  1. added
    bugSomething isn't working
    app:clientRelated to client app
    app:serverRelated to server app
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app:clientRelated to client appapp:serverRelated to server appbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions