sveltejs / sveltejs/kit

Warn when accessing locals during prerendering

Open
#11,995 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
20.8k
Forks
2.3k
Avg merge
1d 16h
Merged PRs (30d)
156

Description

Describe the problem

A user on Discord needed days to solve a problem.
The reason for this was that some routes were prerendered, which the helpers on Discord were not aware of.
See #11981

Describe the proposed solution

Print a warning when accessing locals during prerendering.
This could lead to some false positives, as some store a database connection to event.locals which gets used to fetch content while prerendering. However, I think this is a minority.

Alternatives considered

Do nothing.

Importance

would make my life easier

Additional Information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the prerendering flow and how event.locals is accessed during it; the issue provides no file or test path. Done means accesses to locals during prerendering produce a warning while the documented false-positive case remains understood and covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.