evidence icon indicating copy to clipboard operation
evidence copied to clipboard

[Bug]: routes were marked as prerenderable, but were not prerendered because they were not found in `<Details/>`

Open tpot opened this issue 1 year ago • 2 comments

Describe the bug

I saw this error a while back and re-arranged my markup to make it go away but now I've figured out what the problem is.

If all references to a templated page by components are enclosed in <Details> tags, then the pre-rendering process run during npm run build is not called. The error "Error: The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app" is generated and the build fails.

When I move the component outside of <Details> or remove the <Details> tag entirely, the error goes away. It doesn't matter whether the SQL is inside the tag or out.

I'm happy to admit that my overuse of <Details> was a terrible idea aesthetically and I'll try to avoid it in the future. 😄

Steps to Reproduce

Put the component markup for a templated page inside a <Details> tag.

Logs

node:internal/event_target:1094
  process.nextTick(() => { throw err; });
                           ^
Error: The following routes were marked as prerenderable, but were not prerendered because they were not found while crawling your app:
  - /misc/school_browser/schools/[school_id]

See https://kit.svelte.dev/docs/page-options#prerender-troubleshooting for info on how to solve this
    at prerender (file:///Users/s610249/repos/evidence/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:495:9)
    at async MessagePort.<anonymous> (file:///Users/s610249/repos/evidence/node_modules/@sveltejs/kit/src/utils/fork.js:22:16)
Emitted 'error' event on Worker instance at:
    at [kOnErrorMessage] (node:internal/worker:326:10)
    at [kOnMessage] (node:internal/worker:337:37)
    at MessagePort.<anonymous> (node:internal/worker:232:57)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:820:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28)

Node.js v20.15.1
Build failed

file:///Users/s610249/repos/evidence/node_modules/@evidence-dev/evidence/cli.js:190
			throw `Build process exited with code ${code}`;
			^
Build process exited with code 1
(Use `node --trace-uncaught ...` to show where the exception was thrown)

Node.js v20.15.1
make: *** [default] Error 1

System Info

System:
    OS: macOS 14.4
    CPU: (8) arm64 Apple M3
    Memory: 156.42 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 20.15.1 - ~/homebrew/opt/node@20/bin/node
    npm: 10.7.0 - ~/homebrew/opt/node@20/bin/npm
  Browsers:
    Chrome: 129.0.6668.71
    Safari: 17.4
  npmPackages:
    @evidence-dev/bigquery: ^2.0.8 => 2.0.8 
    @evidence-dev/core-components: ^4.8.4 => 4.8.4 
    @evidence-dev/csv: ^1.0.12 => 1.0.12 
    @evidence-dev/databricks: ^1.0.7 => 1.0.7 
    @evidence-dev/duckdb: ^1.0.11 => 1.0.11 
    @evidence-dev/evidence: ^39.1.10 => 39.1.10 
    @evidence-dev/motherduck: ^1.0.2 => 1.0.2 
    @evidence-dev/mssql: ^1.0.10 => 1.0.10 
    @evidence-dev/mysql: ^1.1.3 => 1.1.3 
    @evidence-dev/postgres: ^1.0.6 => 1.0.6 
    @evidence-dev/snowflake: ^1.1.2 => 1.1.2 
    @evidence-dev/sqlite: ^2.0.6 => 2.0.6 
    @evidence-dev/trino: ^1.0.8 => 1.0.8 

Severity

annoyance

Additional Information, or Workarounds

Workaround is don't use detail tags for template pages.

tpot avatar Oct 01 '24 22:10 tpot

Another workaround

Put empty links to your templated pages outside the details components

<a href="/misc/school_browser/schools/foobar"></a>

they won't be visible to the user, but they will be visible to the crawler

archiewood avatar Oct 02 '24 00:10 archiewood

Why?

  • Anything not visible to the page on start is not in the pre-rendered DOM by default.
  • Details components are closed by default, so their content is not in the pre-rendered DOM
  • This means the links do not exist in pre-rendered HTML, and there is nothing for the crawler to pick up to determine which pre-rendered page to build.

Meta commentary

Generally there are a lot of foot guns with templated page links - we aim to improve the usability of these in the future.

Potential solutions

  • Allow users to specify which pages will be built using a query, and pass these to the crawler
  • Allow users to include templated pages in the sidebar

archiewood avatar Oct 02 '24 00:10 archiewood