vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.
https://vike.dev
MIT License
4.4k stars 353 forks source link

Vike/Vite `renderPage` function slowness (1+ min) #1951

Closed mara-schulke closed 2 weeks ago

mara-schulke commented 2 weeks ago

Description

Hi there! Thank you for providing this awesome project!

Context

I want to preface this bug report (whilst im a little unsure whether its rooted in vike or vite) that Vike got us quite far moving from a purely pre built and client rendered react application to a SSR (capable) approach with our own node server, a great routing system etc.

We did also make the move to a nx powered, not eagerly compiled mono repo fwiw, so packages contain source code that is installed into node modules and only then gets compiled.

Problem

The problem we are seeing is some huge spikes in initial render times as compared to a minimal viable examples. Read: 1 minute to render the initial page – I pinned this down to the await renderPage(ctx) specifically so this comes from either vike or vite behaving unexpectedly slow in our environment. I would like to understand why and to ship a fix!

Have you encountered this before / any clues what may cause this? I could imagine it being unable for you to reproduce due to the close coupling with our concrete repository.

Vite Config / Version

Version(s):

vite:
  specifier: ^5.4.10
  version: 5.4.10(@types/node@22.1.0)
'@vitejs/plugin-react':
  specifier: ^4.2.1
  version: 4.3.0(vite@5.4.10)

vite.config.ts

export default defineConfig({
  plugins: [react(), vike()],
  build: {
    target: 'ES2022',
  }
})

Vike Config

Version(s):

vike:
  specifier: ^0.4.182
  version: 0.4.182(vite@5.4.10)
vike-react:
  specifier: ^0.5.1
  version: 0.5.1(react-dom@18.3.1)(react@18.3.1)(vike@0.4.182)(vite@5.4.10)

pages/+config.ts:

import vikeReact from 'vike-react/config';
import type { Config } from 'vike/types';

export const config = {
  title: '<redacted>',
  stream: false,
  ssr: false,
  bodyAttributes: { class: 'dark' },
  extends: vikeReact,
} satisfies Config;
mara-schulke commented 2 weeks ago

Only log output, eventually interesting:

[vike][Warning] Crawling your + files took an unexpected long time (3.3 seconds). If you consistently get this warning, then consider reaching out on GitHub.