Skip to content

404 errors in interactive mode: contenthash filename mismatch in loader.js after PR #41 #45

@robcmills

Description

@robcmills

Disclosure

This issue was found, analyzed, and filed by a Claude Code agent (Claude Opus 4.6) on behalf of GitHub user @robcmills. Rob reviewed the analysis and condoned opening this issue. Totally understand if you'd prefer not to accept issues from agents, but this is a real bug that affected our project and we wanted to report it upstream. Happy to answer questions or provide more context.

Environment

  • cypress-rspack-dev-server: 1.1.1
  • cypress: 15.13.0
  • @rspack/core: 1.7.7
  • @rspack/dev-server: 1.2.1
  • Mode: interactive/open (cypress open --component)

Bug Description

When running component tests in interactive (open) mode, two 404 errors appear in the browser console on every spec run:

GET http://localhost:8080/__cypress/iframes/undefined 404 (Not Found)
GET http://localhost:8080/__cypress/src/spec-0.js 404 (Not Found)

Tests still pass — the errors are non-blocking — but they produce noisy console output and could mask real issues.

Root Cause: contenthash filename mismatch after PR #41

PR #41 changed the output filename in makeDefaultRspackConfig.js (line 31) from [name].js to [name].[contenthash].js to fix a chunk-loading conflict. However, loader.js (line 28) still hardcodes the URL without the content hash:

// loader.js:28
relativeUrl: "/__cypress/src/${chunkName}.js",
// Generates: /__cypress/src/spec-0.js

But the actual compiled file is something like spec-0.abc123def.js (with the content hash). So the relativeUrl 404s because no file exists at spec-0.js.

This doesn't break test execution because Cypress loads specs through the shouldLoad() + dynamic import() mechanism in the loader, not through the relativeUrl fetch. But Cypress's runner does attempt to fetch relativeUrl (likely for sourcemap resolution), producing the 404.

Suggested fix

Either:

  1. Update loader.js to not hardcode .js and instead derive the actual hashed filename from the compilation output
  2. Or remove [contenthash] from the filename template and find an alternative fix for the original chunk conflict that PR fix: avoid filename conflict #41 addressed

Secondary issue: iframes/undefined race condition

The /__cypress/iframes/undefined 404 appears to be a timing issue where Cypress constructs the iframe URL before spec.absolute is populated. This may be related to the dev-server:compile:success event being emitted (in CypressCTRspackPlugin.js:104) before the spec list is fully synchronized via dev-server:specs:changed. This only occurs in interactive mode — in headless/run mode, justInTimeCompile changes the timing so specs are pre-compiled before the runner loads them.

Reproduction

  1. Configure cypress-rspack-dev-server with any React project using rspack
  2. Run cypress open --component
  3. Click any spec to run it
  4. Open browser DevTools console — observe the two 404 errors

The errors do not appear when running headless (cypress run --component).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions