kettanaito / remix-og-image

Build-time in-browser Open Graph image generation for Remix.
https://npm.im/remix-og-image
26 stars 1 forks source link

"Request is outdated" on Vite preview sometimes #11

Open kettanaito opened 4 weeks ago

kettanaito commented 4 weeks ago

This happens intermittently during the build sometimes:

Error: The server is being restarted or closed. Request is outdated
    at throwClosedServerError (file:///Users/kettanaito/Documents/web/vite-remix-og-image-plugin/node_modules/.pnpm/vite@5.4.1_@types+node@20.14.15/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:48746:15)
    at PluginContainer.resolveId (file:///Users/kettanaito/Documents/web/vite-remix-og-image-plugin/node_modules/.pnpm/vite@5.4.1_@types+node@20.14.15/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:48900:33)
    at ModuleGraph.resolveId (file:///Users/kettanaito/Documents/web/vite-remix-og-image-plugin/node_modules/.pnpm/vite@5.4.1_@types+node@20.14.15/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:62691:29)
    at ModuleGraph._resolveUrl (file:///Users/kettanaito/Documents/web/vite-remix-og-image-plugin/node_modules/.pnpm/vite@5.4.1_@types+node@20.14.15/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:62511:52)
    at ModuleGraph.getModuleByUrl (file:///Users/kettanaito/Documents/web/vite-remix-og-image-plugin/node_modules/.pnpm/vite@5.4.1_@types+node@20.14.15/node_modules/vite/dist/node/chunks/dep-Cy9twKMn.js:62262:30)
    at addFromUrl (/node_modules/.pnpm/@remix-run+dev@2.11.2_@remix-run+react@2.11.2_@remix-run+serve@2.11.2_@types+node@20.12.12_ty_ckffa5sne7pkspnm75mfxrd45e/node_modules/@remix-run/dev/dist/vite/styles.js:115:39)
    at /node_modules/.pnpm/@remix-run+dev@2.11.2_@remix-run+react@2.11.2_@remix-run+serve@2.11.2_@types+node@20.12.12_ty_ckffa5sne7pkspnm75mfxrd45e/node_modules/@remix-run/dev/dist/vite/styles.js:122:65
    at Array.forEach (<anonymous>)
    at findDeps (/node_modules/.pnpm/@remix-run+dev@2.11.2_@remix-run+react@2.11.2_@remix-run+serve@2.11.2_@types+node@20.12.12_ty_ckffa5sne7pkspnm75mfxrd45e/node_modules/@remix-run/dev/dist/vite/styles.js:122:36)
    at getStylesForFiles (/node_modules/.pnpm/@remix-run+dev@2.11.2_@remix-run+react@2.11.2_@remix-run+serve@2.11.2_@types+node@20.12.12_ty_ckffa5sne7pkspnm75mfxrd45e/node_modules/@remix-run/dev/dist/vite/styles.js:78:13)
    at async Object.getStylesForUrl (/node_modules/.pnpm/@remix-run+dev@2.11.2_@remix-run+react@2.11.2_@remix-run+serve@2.11.2_@types+node@20.12.12_ty_ckffa5sne7pkspnm75mfxrd45e/node_modules/@remix-run/dev/dist/vite/styles.js:165:16)
    at async requestHandler (/node_modules/.pnpm/@remix-run+server-runtime@2.11.2_typescript@5.4.5/node_modules/@remix-run/server-runtime/dist/server.js:159:66)
    at async /node_modules/.pnpm/@remix-run+dev@2.11.2_@remix-run+react@2.11.2_@remix-run+serve@2.11.2_@types+node@20.12.12_ty_ckffa5sne7pkspnm75mfxrd45e/node_modules/@remix-run/dev/dist/vite/cloudflare-proxy-plugin.js:70:25 {
  code: 'ERR_CLOSED_SERVER'
}

When looking at the preview, sometimes Vite spawns but the app is a blank page that has to be reloaded. Not sure if this is caused by the plugin, but it needs to make sure that if the browser opens such page, it reloads before proceeding with taking the screenshot.

kettanaito commented 3 weeks ago

This needs additional testing after #14, which moves the Vite preview server spawning to the beginning of the build (so it spawns as the build is in progress).

kettanaito commented 2 weeks ago

This happened to me once when running build while the serve was also running. Perhaps this error is an indicator that Vite preview conflicts with Vite build.

That shouldn't be the case anymore after #14, since those changes move vite preview to be in parallel with the build, but run it only when the build is complete.