windmill-labs/windmill · info

Source map not found

Error message

Source map not found

What it means

Requests for the JS source map `/dist/bundle.js.map` (or `/bundle.js.map`) are served from `<cwd>/dist/bundle.js.map` with application/json content type; if the map file is missing the dev server replies 404 'Source map not found'. Source maps are optional debug artifacts, so this error only affects debugging (stack traces pointing at original sources), not app functionality.

Source

Thrown at cli/src/commands/app/dev.ts:949

      const cssPath = path.join(process.cwd(), "dist/bundle.css");
      if (fs.existsSync(cssPath)) {
        res.writeHead(200, { "Content-Type": "text/css" });
        res.end(fs.readFileSync(cssPath));
      } else {
        res.writeHead(404);
        res.end("CSS not found");
      }
      return;
    }

    // Serve source maps
    if (url === "/dist/bundle.js.map" || url === "/bundle.js.map") {
      const mapPath = path.join(process.cwd(), "dist/bundle.js.map");
      if (fs.existsSync(mapPath)) {
        res.writeHead(200, { "Content-Type": "application/json" });
        res.end(fs.readFileSync(mapPath));
      } else {
        res.writeHead(404);
        res.end("Source map not found");
      }
      return;
    }

    if (url === "/dist/bundle.css.map" || url === "/bundle.css.map") {
      const mapPath = path.join(process.cwd(), "dist/bundle.css.map");
      if (fs.existsSync(mapPath)) {
        res.writeHead(200, { "Content-Type": "application/json" });
        res.end(fs.readFileSync(mapPath));
      } else {
        res.writeHead(404);
        res.end("Source map not found");
      }
      return;
    }

    // Serve injected HTML for root and any other path

View on GitHub (pinned to e474e8803c)

Solutions

  1. Rebuild with source maps enabled so dist/bundle.js.map is emitted (e.g. set `sourcemap: true` in the bundler config or drop --no-sourcemap).
  2. If maps are intentionally disabled, ignore the 404 or remove/condition the sourceMappingURL comment in the generated bundle.
  3. Confirm the CLI runs from the app root so the map is looked up in the correct dist/.
  4. Stop stripping .map files from dist/ in clean/deploy scripts if you need devtools debugging.
  5. Hard-reload the browser after regenerating maps so devtools refetches /dist/bundle.js.map.

Example fix

// before: bundler config without maps
export default { sourcemap: false };

// after
export default { sourcemap: true }; // emits dist/bundle.js.map
Defensive patterns

Strategy: validation

Validate before calling

const mapPath = require('path').join(process.cwd(), 'dist/bundle.js.map');
if (!require('fs').existsSync(mapPath)) {
  console.warn('No JS source map; devtools will show bundled code only');
}

Try / catch

try {
  const map = fs.readFileSync(path.join(process.cwd(), 'dist/bundle.js.map'));
  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(map);
} catch (err) {
  if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
    res.writeHead(404);
    res.end('Source map not found');
  } else { throw err; }
}

Prevention

When it happens

Trigger: Browser devtools request /dist/bundle.js.map (because bundle.js references it via //# sourceMappingURL, or devtools 'enable source maps' is on) while `fs.existsSync(process.cwd() + '/dist/bundle.js.map')` is false — bundler built without sourcemaps or cleaned them.

Common situations: Production-style build with sourcemaps disabled (`sourcemap: false` / --no-sourcemap) served through dev; dist cleaned of .map files to save space; bundler version change altering sourcemap output; loading dev server from the wrong cwd.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/aea5dde18ab56b15. Report an issue: GitHub.