sveltejs/kit · error · AggregateError

${log.message ?? String(log)}

Error message

${log.message ?? String(log)}

What it means

This is the per-log message formatting inside adapter-bun's build failure path: when Bun's build fails, its BuildMessage objects have non-enumerable properties, so the adapter extracts log.message ?? String(log) and surfaces it via builder.log before throwing an AggregateError containing all logs.

Source

Thrown at packages/adapter-bun/index.js:267

				files: virtual_files,
				outdir: out,
				compile: buildOptions.compile
					? {
							outfile: 'server',
							...(typeof buildOptions.compile === 'string' ? { target: buildOptions.compile } : {}),
							...(typeof buildOptions.compile === 'object' ? buildOptions.compile : {})
						}
					: false
			});
			if (!result.success) {
				for (const log of result.logs) {
					// BuildMessage properties are not enumerable, so console.error(log) prints `{}`
					const message = log.message ?? String(log);
					if (log.level === 'error') builder.log.error(message);
					else if (log.level === 'warning') builder.log.warn(message);
					else builder.log.info(message);
				}
				throw new AggregateError(result.logs);
			}
		},

		supports: {
			read: () => true,
			instrumentation: () => true
		}
	};
}

/**
 * @param {object} options
 * @param {Builder} options.builder
 * @param {string[]} options.server_assets
 * @returns {Promise<{imports: string[], entries: string[], server_assets: string[]}>}
 */
async function get_embed_entries({ builder, server_assets }) {
	const built_files = `${builder.config.outDir}/output`;

View on GitHub (pinned to 03f1687fe6)

Solutions

  1. Read the surfaced log messages (and the AggregateError's errors array) for the underlying Bun build failure and fix the reported source file/line.
  2. Run the Bun build step directly to see Bun's native diagnostics.
  3. Check for unresolved imports or invalid syntax introduced by recent changes.
  4. Update Bun, since newer versions produce more descriptive BuildMessages.

Example fix

// before
// console.error(log) prints `{}` because BuildMessage props are non-enumerable
// after
const message = log.message ?? String(log);
builder.log.error(message);
Defensive patterns

Strategy: try-catch

Validate before calling

import { spawnSync } from 'node:child_process';
const r = spawnSync('bun', ['--version']);
if (r.error || r.status !== 0) throw new Error('Bun not available — install Bun before building');

Type guard

const isBuildMessage = (log) => typeof log === 'object' && log !== null && ('message' in log || 'level' in log);

Try / catch

try {
  await build();
} catch (e) {
  if (e instanceof AggregateError) {
    for (const log of e.errors) {
      const msg = log.message ?? String(log);
      console.error(`[bun build ${log.level ?? 'error'}] ${msg}`);
    }
    process.exit(1);
  }
  throw e;
}

Prevention

When it happens

Trigger: A Bun build invoked during adapt returned failure; the adapter iterates result.logs, stringifies each BuildMessage with this expression, logs it, and then throws new AggregateError(result.logs).

Common situations: Syntax errors or unresolved imports in bundled client/server code; Bun compiler errors; logs printing `{}` when message extraction is missing; AggregateError.errors holding the individual BuildMessages.

Related errors


AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02). Data as JSON: /api/errors/169f83b2f0951493. Report an issue: GitHub.