Skip to content
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

fix: avoid nextjs unsafeCache and watchOptions #20440

Merged
merged 7 commits into from
Mar 3, 2022

Conversation

elevatebart
Copy link
Contributor

@elevatebart elevatebart commented Mar 1, 2022

In webpack 5 it seems that loaders called with the exact same query are not re-run.
This creates a situation where the Cypress file watcher is updating the files but the new files are never pushed in the loader. It results in Cypress throwing a (No tests found) error since the spec exists but not in the AUT.

In this PR I disable caching and unsafe caching for the browser.js file.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Mar 1, 2022

Thanks for taking the time to open a PR!

@elevatebart elevatebart marked this pull request as ready for review March 2, 2022 00:02
@cypress
Copy link

cypress bot commented Mar 2, 2022



Test summary

19278 0 218 0Flakiness 5


Run details

Project cypress
Status Passed
Commit 8e451b1
Started Mar 3, 2022 7:06 PM
Ended Mar 3, 2022 7:18 PM
Duration 11:46 💡
OS Linux Debian - 10.10
Browser Multiple

View run in Cypress Dashboard ➡️


Flakiness

commands/net_stubbing_spec.ts Flakiness
1 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
2 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
settings_spec.js Flakiness
1 Settings > file preference panel > loads preferred editor, available editors and shows spinner
cypress/proxy-logging_spec.ts Flakiness
1 ... > works with forceNetworkError
2 Proxy Logging > request logging > xhr log has response body/status code

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

Copy link
Contributor

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Any perf implication?
  2. CI is failing hardcore - did this cause that?
  3. Gonna need to add a test for this somehow - it's not even clear how to test by hand, but we definitely need some kind of automated testing here.

As for the actual implementation, cool hack, no idea if there's a better/cleaner way (likely, but I don't know what it is).

@BlueWinds is working around webpack lately, they may be interested to see this PR/issue.

@ZachJW34
Copy link
Contributor

ZachJW34 commented Mar 2, 2022

Can you add some information on how you tested this? I pulled it down and I wasn't able to get a new spec detected. When I cleared the next webpack cache, I started receiving this error:
Screen Shot 2022-03-02 at 9 43 54 AM

Also, this seems to be a next issue, not a webpack 5 issue. Both cra-5 and vue-cli-5 (which uses webpack 5) doesn't have this problem, so I wonder if we should dig into what the Next webpack config is doing that causes this refresh issue rather than make a change to the @cypress/webpack-dev-server.

Copy link
Contributor

@ZachJW34 ZachJW34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is any good way to test this. We could probably write a unit test where we spin up a dev-server with a Next webpack config, touch a file and assert that webpack recompiles but we would need to have Next v12 installed. I would take note of this since our testing is lacking in this area

@@ -41,6 +41,15 @@ async function getNextWebpackConfig (config) {

checkSWC(nextWebpackConfig, config)

if (nextWebpackConfig.watchOptions && Array.isArray(nextWebpackConfig.watchOptions?.ignored)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remove the optional chaining as this will fail on node v12

@elevatebart elevatebart changed the title fix: force webpack to re-run the loader fix: avoid nextjs unsafeCache and watchOptions Mar 3, 2022
@elevatebart elevatebart merged commit 9f60901 into master Mar 3, 2022
@elevatebart elevatebart deleted the elevatebart/fix/force-cache-bust-on-nextjs branch March 3, 2022 20:15
@elevatebart elevatebart mentioned this pull request Mar 3, 2022
5 tasks
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.

3 participants