[🐞] Optimizer should find all qrls inside qrls even when only building for client or server
Open
Nobody has claimed this yet.
bug
optimizer
- Dominant language
- TypeScript
- Stars
- 22.1k
- Forks
- 1.4k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
Which component is affected?
Qwik Runtime
Describe the bug
6:04:20 PM [vite] Internal server error: invoke: qrl $captureRef$ must be defined inside useLexicalScope()
File: /home/projects/qwik-starter-ydb5i8/src/routes/index.tsx:17:48
at createError (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:163:17)
at logError (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:157:54)
at logErrorAndStop (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:167:17)
at assertDefined (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:407:15)
at Proxy.useLexicalScope (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:4991:9)
at eval (/home/projects/qwik-starter-ydb5i8/src/routes/index.tsx:17:48)
at invoke (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:1420:26)
at eval (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:6776:35)
at async invokeQRL (file://file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik/core.mjs:6795:24)
at async pureServerFunction (file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik-city/vite/index.cjs:23722:26)
at async Object.next (file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik-city/vite/index.cjs:23930:9)
at async runNext (file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik-city/vite/index.cjs:24128:5)
at async eval (file:///home/projects/qwik-starter-ydb5i8/node_modules/@builder.io/qwik-city/vite/index.cjs:24537:26)
Reproduction
https://stackblitz.com/edit/qwik-starter-ydb5i8?file=src%2Froutes%2Findex.tsx,package.json
Steps to reproduce
No response
System Info
n/a
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction, especially src/routes/index.tsx and package.json, and reproduce the error in the client-only or server-only build. Trace how the optimizer discovers nested QRLs; the issue is done when all nested QRLs are found and the reproduction no longer raises the useLexicalScope error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100