Skip to content

Cannot show AggreateError nicely when there is a build error #21666

@uhyo

Description

@uhyo

Describe the bug

When an AggregateError is thrown during build, the console log doesn't print the errors that consist of it.

colors.red(`error during build:\n${e.stack}`),

Reproduction

https://stackblitz.com/edit/vitejs-vite-amnehxld?file=vite.config.ts&terminal=dev

Steps to reproduce

  1. Prepare vite.config.ts with below contents
  2. npm run build
  3. See the error message and confirm that only Aggregate error is shown as error message, hiding concrete errors (Error 1 and Error 2)
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [
    {
      name: "repro-plugin",
      async buildApp() {
        const error1 = new Error("Error 1");
        const error2 = new Error("Error 2");
        throw new AggregateError([error1, error2], "Aggregate error");
      }
    }
  ],
});

System Info

System:
    OS: Linux 6.6 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 PRO 6850U with Radeon Graphics
    Memory: 7.54 GB / 15.01 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 24.13.1 - /home/uhyo/.volta/tools/image/node/24.13.1/bin/node
    Yarn: 4.1.1 - /home/uhyo/.volta/tools/image/yarn/4.1.1/bin/yarn
    npm: 11.4.2 - /home/uhyo/.volta/tools/image/npm/11.4.2/bin/npm
    pnpm: 10.25.0 - /home/uhyo/.volta/bin/pnpm
    Deno: 2.2.1 - /home/uhyo/.deno/bin/deno
  npmPackages:
    vite: ^8.0.0-beta.13 => 8.0.0-beta.15

Used Package Manager

npm

Logs

> vite-project@0.0.0 build
> vite build

error during build:
AggregateError: Aggregate error
    at BasicMinimalPluginContext.buildApp (file:///tmp/vite-project/node_modules/.vite-temp/vite.config.ts.timestamp-1771502762114-f6c51e4620c3.mjs:89:9)
    at Object.buildApp (file:///tmp/vite-project/node_modules/vite/dist/node/chunks/node.js:33107:32)
    at CAC.<anonymous> (file:///tmp/vite-project/node_modules/vite/dist/node/cli.js:641:17)

Validations

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions