Skip to content

fix(qwik): defer context access until visible lifecycle - #389

Merged
vamgan merged 1 commit into
mainfrom
fix/qwik-context-lifecycle
Jul 26, 2026
Merged

vamgan merged 1 commit into
mainfrom
fix/qwik-context-lifecycle

Conversation

@vamgan

@vamgan vamgan commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • replace render-time Qwik context dereferences with a stable NoSerialize context signal populated by the visible lifecycle
  • resolve context readiness at action/task time across stream, chat, history, source, and agent hooks
  • add QRL factories for SSR-resumable hook-owned contexts and custom sources while preserving client-only direct-object support
  • add optimizer-backed rendered lifecycle regressions and document the lifecycle contract

Closes #372.

Why

Qwik component setup runs before useVisibleTask$. The adapter previously destructured a getter backed by a local context variable during setup, permanently capturing the unavailable value. Optimizer-backed rendering also demonstrated that mutating that captured local is incompatible with Qwik's transformed lifecycle.

The new ctxRef signal keeps the render-time reference stable while the browser-only context remains NoSerialize. Dependent hooks read it only when a visible task or action actually needs the context.

Validation

  • npm run build -w @askable-ui/qwik
  • npm test -w @askable-ui/qwik — 29 tests, including 5 optimizer-backed rendered lifecycle tests
  • npm audit --omit=dev --audit-level=high
  • npm run build
  • npm test — 1,162 tests
  • npm ci && npm run build in site/docs
  • git diff --check

Follow-up

Optimizer-backed investigation also found the broader pre-existing Qwik action-QRL limitation tracked separately in #388. This PR stays focused on context readiness and does not introduce a breaking action/callback API migration.

@vercel

vercel Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
askable Ready Ready Preview, Comment Jul 26, 2026 1:16am

@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown

Open in StackBlitz

@askable-ui/angular

npm i https://pkg.pr.new/@askable-ui/angular@389

@askable-ui/context

npm i https://pkg.pr.new/@askable-ui/context@389

@askable-ui/core

npm i https://pkg.pr.new/@askable-ui/core@389

@askable-ui/create-app

npm i https://pkg.pr.new/@askable-ui/create-app@389

@askable-ui/mcp

npm i https://pkg.pr.new/@askable-ui/mcp@389

@askable-ui/qwik

npm i https://pkg.pr.new/@askable-ui/qwik@389

@askable-ui/react

npm i https://pkg.pr.new/@askable-ui/react@389

@askable-ui/react-native

npm i https://pkg.pr.new/@askable-ui/react-native@389

@askable-ui/solid

npm i https://pkg.pr.new/@askable-ui/solid@389

@askable-ui/svelte

npm i https://pkg.pr.new/@askable-ui/svelte@389

@askable-ui/vue

npm i https://pkg.pr.new/@askable-ui/vue@389

@askable-ui/web-component

npm i https://pkg.pr.new/@askable-ui/web-component@389

commit: 98ce831

@vamgan
vamgan merged commit 7f1a481 into main Jul 26, 2026
9 checks passed
@vamgan
vamgan deleted the fix/qwik-context-lifecycle branch July 26, 2026 01:19

This branch was successfully deployed

1 active deployment
Preview — 98ce831a Deployed Jul 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(qwik): hooks capture a null context before visible task initialization

1 participant