{"record":{"id":"a25d7d43d5921a9f","repo":"angular/angular-cli","slug":"webpack-stats-build-result-is-required-a25d7d","errorCode":null,"errorMessage":"Webpack stats build result is required.","messagePattern":"Webpack stats build result is required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular_devkit/build_angular/src/builders/dev-server/webpack-server.ts","lineNumber":224,"sourceCode":"    }\n\n    return {\n      browserOptions,\n      webpackConfig,\n    };\n  }\n\n  return from(setup()).pipe(\n    switchMap(({ browserOptions, webpackConfig }) => {\n      return runWebpackDevServer(webpackConfig, context, {\n        logging: transforms.logging || createWebpackLoggingCallback(browserOptions, logger),\n        webpackFactory: require('webpack') as typeof webpack,\n        webpackDevServerFactory: require('webpack-dev-server') as typeof webpackDevServer,\n      }).pipe(\n        concatMap(async (buildEvent, index) => {\n          const webpackRawStats = buildEvent.webpackStats;\n          if (!webpackRawStats) {\n            throw new Error('Webpack stats build result is required.');\n          }\n\n          // Resolve serve address.\n          const publicPath = webpackConfig.devServer?.devMiddleware?.publicPath;\n\n          const serverAddress = url.format({\n            protocol: options.ssl ? 'https' : 'http',\n            hostname: options.host === '0.0.0.0' ? 'localhost' : options.host,\n            port: buildEvent.port,\n            pathname: typeof publicPath === 'string' ? publicPath : undefined,\n          });\n\n          if (index === 0) {\n            logger.info(\n              '\\n' +\n                tags.oneLine`\n              **\n              Angular Live Development Server is listening on ${options.host}:${buildEvent.port},","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular_devkit/build_angular/src/builders/dev-server/webpack-server.ts#L206-L242","documentation":"serveWebpackBrowser subscribes to the webpack build observable and each emitted build event must include webpackStats; stats drive public path resolution, address logging, and dev middleware behavior. A build event without stats indicates a malformed build result, so the server throws rather than serving without necessary metadata.","triggerScenarios":"A webpack build event reaches concatMap without webpackStats — caused by custom webpack configuration transforms stripping stats, incompatible/patched webpack or webpack-dev-server versions not attaching stats to dev middleware events, or wrapping/rebuilding the build observable and dropping fields.","commonSituations":"Custom dev-server wrappers or internal CLI tooling re-emitting build events; webpack-dev-server major version mismatch (v3/v4) after an incomplete upgrade; plugins that replace devMiddleware and omit stats output; running patched builds of @angular-devkit/build-angular.","solutions":["Ensure the full build event (including webpackStats) is forwarded — remove map/reconstruct operations on the build observable.","Align webpack/webpack-dev-server versions with those required by @angular-devkit/build-angular (clean reinstall).","Remove or update custom transforms that touch webpackConfiguration and could suppress stats generation.","Verify with a stock 'ng serve' on an unmodified project, then reintroduce customizations one at a time."],"exampleFix":"// before\nreturn build.pipe(map(ev => ({ ...ev, webpackStats: undefined })));\n// after\nreturn build; // keep webpackStats on every build event","handlingStrategy":"type-guard","validationCode":"import type { BuildEvent } from '@angular-devkit/build-angular';\nfunction hasStats(ev: Partial<BuildEvent>): ev is BuildEvent & { webpackStats: NonNullable<BuildEvent['webpackStats']> } {\n  return !!ev.webpackStats;\n}","typeGuard":"const hasWebpackStats = (ev: { webpackStats?: unknown }): ev is { webpackStats: NonNullable<typeof ev.webpackStats> } =>\n  ev.webpackStats != null;","tryCatchPattern":"try {\n  await startWebpackDevServer();\n} catch (e) {\n  if (String(e.message).includes('Webpack stats build result is required')) {\n    // forward original build events; check webpack-dev-server version alignment\n  }\n  throw e;\n}","preventionTips":["Forward webpack build events unmodified through wrappers","Keep webpack and webpack-dev-server versions matched to build-angular","Avoid replacing devMiddleware with custom implementations","Test serve after every build-toolchain upgrade"],"tags":["angular","dev-server","webpack","stats"],"backgroundTag":"webpack-stats-missing","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}