{"record":{"id":"169f83b2f0951493","repo":"sveltejs/kit","slug":"log-message-string-log","errorCode":null,"errorMessage":"${log.message ?? String(log)}","messagePattern":"\\$\\{log\\.message \\?\\? String\\(log\\)\\}","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/adapter-bun/index.js","lineNumber":267,"sourceCode":"\t\t\t\tfiles: virtual_files,\n\t\t\t\toutdir: out,\n\t\t\t\tcompile: buildOptions.compile\n\t\t\t\t\t? {\n\t\t\t\t\t\t\toutfile: 'server',\n\t\t\t\t\t\t\t...(typeof buildOptions.compile === 'string' ? { target: buildOptions.compile } : {}),\n\t\t\t\t\t\t\t...(typeof buildOptions.compile === 'object' ? buildOptions.compile : {})\n\t\t\t\t\t\t}\n\t\t\t\t\t: false\n\t\t\t});\n\t\t\tif (!result.success) {\n\t\t\t\tfor (const log of result.logs) {\n\t\t\t\t\t// BuildMessage properties are not enumerable, so console.error(log) prints `{}`\n\t\t\t\t\tconst message = log.message ?? String(log);\n\t\t\t\t\tif (log.level === 'error') builder.log.error(message);\n\t\t\t\t\telse if (log.level === 'warning') builder.log.warn(message);\n\t\t\t\t\telse builder.log.info(message);\n\t\t\t\t}\n\t\t\t\tthrow new AggregateError(result.logs);\n\t\t\t}\n\t\t},\n\n\t\tsupports: {\n\t\t\tread: () => true,\n\t\t\tinstrumentation: () => true\n\t\t}\n\t};\n}\n\n/**\n * @param {object} options\n * @param {Builder} options.builder\n * @param {string[]} options.server_assets\n * @returns {Promise<{imports: string[], entries: string[], server_assets: string[]}>}\n */\nasync function get_embed_entries({ builder, server_assets }) {\n\tconst built_files = `${builder.config.outDir}/output`;","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/adapter-bun/index.js#L249-L285","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Read the surfaced log messages (and the AggregateError's errors array) for the underlying Bun build failure and fix the reported source file/line.","Run the Bun build step directly to see Bun's native diagnostics.","Check for unresolved imports or invalid syntax introduced by recent changes.","Update Bun, since newer versions produce more descriptive BuildMessages."],"exampleFix":"// before\n// console.error(log) prints `{}` because BuildMessage props are non-enumerable\n// after\nconst message = log.message ?? String(log);\nbuilder.log.error(message);","handlingStrategy":"try-catch","validationCode":"import { spawnSync } from 'node:child_process';\nconst r = spawnSync('bun', ['--version']);\nif (r.error || r.status !== 0) throw new Error('Bun not available — install Bun before building');","typeGuard":"const isBuildMessage = (log) => typeof log === 'object' && log !== null && ('message' in log || 'level' in log);","tryCatchPattern":"try {\n  await build();\n} catch (e) {\n  if (e instanceof AggregateError) {\n    for (const log of e.errors) {\n      const msg = log.message ?? String(log);\n      console.error(`[bun build ${log.level ?? 'error'}] ${msg}`);\n    }\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Iterate AggregateError.errors and read .message for real diagnostics","Keep Bun updated for clearer BuildMessage output","Run the Bun build standalone to reproduce bundling errors","Fix the underlying syntax/import errors the logs point to"],"tags":["bun","build","aggregate-error","adapter-bun"],"backgroundTag":"bundler-build-failure","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}