fastify-vite icon indicating copy to clipboard operation
fastify-vite copied to clipboard

clientOnly not updated on reload in dev mode

Open bschelling opened this issue 8 months ago • 1 comments

Prerequisites

  • [x] I have written a descriptive issue title
  • [x] I have searched existing issues to ensure the bug has not already been reported

Fastify version

5.3.2

Plugin version

5.3.2

Node.js version

20.11.0

Operating system

macOS

Operating system version (i.e. 20.04, 11.3, 10)

sequoia

Description

I'm just trying to get started with fastify/vue and checking the basics.

Using the boilerplate "index.vue" I tried to add an onEnter function to change the clientOnly value of the context in dev mode and reloaded the page looking at the source code.

export function onEnter(ctx) {
  ctx.clientOnly = true;
}

Nothing happened, there is still html output in the root div of the sourcecode of the page (using view-source:http://localhost:3000/), although the console shows

[vite] program reload
[vite] program reload

After terminating the server (CTRL + C) and restarting using npm run dev I can see that now the root div is empty, so the content is rendered on the client.

I guess a program reload should be enough to switch the clientOnly rendering behaviour (?)

Link to code that reproduces the bug

https://github.com/bschelling/fastify-vue-clientonly/blob/main/client/pages/index.vue

Expected Behavior

Reload in devmode show switch the clientOnly mode.

bschelling avatar May 12 '25 07:05 bschelling

Thank you! Indeed, there are few parts which are not covered by HMR. This should be fixed in the next release when I finish the second pass at the Vite Environment API — and it'll be able to fully reset the Fastify route handler.

I'll keep this issue to track progress.

galvez avatar May 12 '25 10:05 galvez