vikejs / vike

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

Issue with `injectScriptsAt: "STREAM"` when integrating SolidJS's `renderToStringAsync()` for crawlers. #1856

Closed phonzammi closed 2 months ago

phonzammi commented 2 months ago

Description

When attempting to add support for checking crawlers/bots & integrate renderToStringAsync() to vike-solid in https://github.com/vikejs/vike-solid/pull/117. We encountered a bug: You stumbled upon a Vike bug.

[17:05:52.522][/examples/solid-query][pnpm run dev][stderr] 5:05:52 PM [vike@0.4.193][request(2)][Bug] You stumbled upon a Vike bug. Go to https://github.com/vikejs/vike/issues/new and copy-paste this error. A maintainer will fix the bug (usually under 24 hours).
    at injectHtmlTagsToString (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/html/injectAssets.js:15:5)
    at renderDocumentHtml (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/html/renderHtml.js:38:32)
    at executeOnRenderHtmlHook (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/renderPage/executeOnRenderHtmlHook.js:33:24)
    at renderPageAlreadyRouted (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/renderPage/renderPageAlreadyRouted.js:58:30)
    at renderPageNominal (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/renderPage.js:284:36)
    at renderPageAlreadyPrepared (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/renderPage.js:119:[45](https://github.com/vikejs/vike-solid/actions/runs/10742321893/job/29794694075?pr=117#step:8:46))
    at renderPageAndPrepare (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/renderPage.js:99:12)
    at file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/plugin/shared/getHttpRequestAsyncStore.js:54:35
    at renderPage (file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/runtime/renderPage.js:45:35)
    at file:///home/runner/work/vike-solid/vike-solid/node_modules/.pnpm/vike@0.4.193_vite@5.4.2_@types+node@22.4.0_terser@5.31.6_/node_modules/vike/dist/esm/node/plugin/shared/addSsrMiddleware.js:30:27

This issue occurs when we have a +config.js file like this:

export default {
  stream: true,
  injectScriptsAt: "STREAM",
} satisfies Config;

We set injectScriptsAt: "STREAM", but renderToStringAsync() returns a string, not a stream.