Skip to content

fix: invalidate module in createQwikPlugin slows down cypress component tests #7726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

maiieul
Copy link
Contributor

@maiieul maiieul commented Jul 14, 2025

What is it?

  • Bug

Description

invalidateModule is used for HMR in Vite handleHotUpdate hook. It was added in a69de93 in an attempt to make sure that QRLs also get updated on parent changes.

The problem is that this causes cypress component tests (CCTs) to be 10x slower, eventually leading to CCTs startup timing out with a "Error: Code(5): You can render over a existing q:container. Skipping render()." message.

I tried many possible combinations of updating the child, the parent, the jsx, the useVisibleTask, the useTask, the QRL outside of the component... I haven't been able to trigger a case where the invalidateModule in the transform hook with the optimizer would ever run.

What seems to happen is that the handleHotUpdate hook will invalidate the module, which will then trigger the transform hook for the corresponding module and its QRLs.

Here's an example log:

invalidating module HMR /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx
invalidating module HMR /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx
invalidating module HMR /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx
invalidating module HMR /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx_Counter2_component_div_button_onClick_fDhgqdXxNQQ.js
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx_Counter2_component_yQ6Hre9qSVo.js
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx_Counter2_component_useVisibleTask_ISI2k8PkKII.js
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx_Counter2_component_computedCount_useComputed_OKKHalBLW9E.js
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx_Counter2_component_computedCount_useComputed_OKKHalBLW9E.js
transform /Users/maieul/dev/playgrounds/qwik-express/src/components/counter2.tsx_Counter2_component_useVisibleTask_ISI2k8PkKII.js

Conclusion: We should remove the invalidateModule in the transform hook because it impacts CCTs and it seems to never run. Even if it runs rare occasions, it's more important to enable CCTs to work rather than HMR in rare circumstances.

If someone can give me a reproduction of when QRLs don't get updated on parent change, I can reassess and try to find a fix that works both for CCTs and HMR.

Checklist

  • My code follows the developer guidelines of this project
  • I performed a self-review of my own code
  • I added a changeset with pnpm change
  • I made corresponding changes to the Qwik docs
  • I added new tests to cover the fix / functionality

@maiieul maiieul requested a review from a team as a code owner July 14, 2025 17:23
Copy link

changeset-bot bot commented Jul 14, 2025

⚠️ No Changeset found

Latest commit: 6f45fe9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@maiieul maiieul added TYPE: bug Something isn't working COMP: performance This issue is related to a performance problem or bug labels Jul 14, 2025
@maiieul maiieul self-assigned this Jul 14, 2025
@maiieul maiieul moved this from Backlog to Waiting For Review in Qwik Development Jul 14, 2025
Copy link

pkg-pr-new bot commented Jul 14, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@builder.io/qwik@7726
npm i https://pkg.pr.new/@builder.io/qwik-city@7726
npm i https://pkg.pr.new/eslint-plugin-qwik@7726
npm i https://pkg.pr.new/create-qwik@7726

commit: 6f45fe9

Copy link
Contributor

github-actions bot commented Jul 14, 2025

built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 6f45fe9

@maiieul maiieul removed TYPE: bug Something isn't working COMP: performance This issue is related to a performance problem or bug labels Jul 15, 2025
@maiieul maiieul force-pushed the fix-cypress-component-testing-slowness branch from dee7adf to 6f45fe9 Compare July 15, 2025 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Waiting For Review
Development

Successfully merging this pull request may close these issues.

1 participant