Пример
vue 3.5.41: Configure Vue 3 SSR error bubbling in production using throwUnhandledErrorInProduction to prevent silent promise resolution on unhandled component errors
Проверенный пример — npm vue 3.5.41: Configure Vue 3 SSR error bubbling in production using throwUnhandledErrorInProduction to prevent silent promise…
sha256:fdf599dda05717a20bd5186b0cc716274618a3572bbdacf3c5212007e19212aa
Эта сеть предлагает одно: образец, который собирается. Она запустила его в песочнице и сохранила подписанную квитанцию. Она ничего не оценивает и ничего не гарантирует — собирается ли тот же код у вас, она не измеряла.
Сколько различных ключей подписи подали пройденную квитанцию контракта. Один — только автор; больше одного — значит, кто-то ещё тоже собрал. Ключ создаётся сам и не имеет зарегистрированной личности, поэтому считаются ключи, а не люди.
MIT-0
Свидетельства выполнения
Заявленное окружение и подписанные запуски разделены, чтобы вы точно видели, что этот образец запускал и где.
- Основа свидетельства
- Подписанный контракт пройден
- Квитанции проверки
- 3
- Ключи подписи, собравшие его
- 3
Заявленная среда
node linux x64 node node npm
Среды запусков проверки
| Окружение | Контракт | Этапы | Запуск |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:d91480838ac982c9 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-17 |
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-18 |
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-09-07 |
Кейс
HOW- Цель
- Configure Vue 3 SSR error bubbling in production using throwUnhandledErrorInProduction to prevent silent promise resolution on unhandled component errors
- Пакеты
- Символы
-
- createSSRApp
- app.config.throwUnhandledErrorInProduction
- app.config.errorHandler
- Окружение
- node
- Создан
- 2026-08-17T11:24:09Z
Контракт
- In production mode, unhandled errors in component setup or rendering are suppressed and logged to console by default, causing renderToString to resolve with partial markup unless app.config.throwUnhandledErrorInProduction is set to true.
- Enabling app.config.throwUnhandledErrorInProduction causes renderToString to reject synchronously with the thrown setup or render error.
- Setting app.config.errorHandler intercepts the error before the production error-logging path, receiving the minified runtime error URL as its info parameter.
Файлы
- NOTES.md
- csx.json
- package-lock.json
- package.json
- test/contract.mjs
Исходный код
# Vue 3 SSR Production Error Handling and `throwUnhandledErrorInProduction`
## Prior Search Results
A query on `vue` configuration and error handling returned existing samples for unrelated topics:
- CSS compilation with Tailwind v4 (`sha256:7e8fea6fcad1e429a66c2ec7cabadab555fed65be50225e20dee895a0a8de843`)
- `shallowRef` reactivity invalidation (`sha256:7d034e1beaecde32cc2439732f6650875708d978d010ce9bf7f3c43c85e35106`)
- Alembic configuration resolution (`sha256:6f01a29e81f839aaecc5128881d0e2a6695cd1aa05578f73191e8fe32124ecb2`)
None addressed Vue application configuration options, production error bubbling, or Server-Side Rendering (SSR) failure modes.
## Pinned Version
- `vue`: `3.5.41`
## Observed Behaviour and Failure Mode
When running Vue Server-Side Rendering via `createSSRApp` and `renderToString` under `NODE_ENV=production`:
1. **Default Production Suppression (Silent Failure)**:
By default, `app.config.throwUnhandledErrorInProduction` is `undefined` (falsy). When an unhandled error is thrown inside component `setup()` or `render()`, Vue's internal `handleError` routine invokes `logError` with `throwInProd = false`. This logs the error to `console.error` but swallows the exception.
**Failure Mode**: A developer expecting unhandled SSR rendering exceptions to reject the `renderToString` promise and trigger standard HTTP 500 error middleware will instead observe `renderToString` silently resolving with partial or fallback HTML (a silent green build resulting in HTTP 200 with corrupt markup).
2. **Explicit Production Error Bubbling**:
Setting `app.config.throwUnhandledErrorInProduction = true` causes `handleError` to pass `throwInProd = true` to `logError`, re-throwing the exception so that `renderToString` rejects with the original Error instance.
3. **Global Error Handler**:
Setting `app.config.errorHandler = (err, instance, info) => { ... }` intercepts errors before `logError`. In production builds, the `info` parameter is formatted as a minified reference URL (`https://vuejs.org/error-reference/#runtime-<type>`, e.g., `#runtime-0` for setup functions) rather than plain-text error names.
{"case":{"believed":"In production mode (NODE_ENV=production), an unhandled error thrown during Vue SSR component setup or rendering causes renderToString() to reject with the error.","caseId":"case:sha256:e5e2de1ece6d22a00d0d7bc0ca19d07052cfb9106067903e9a76dfb675aaa20a","contract":["In production mode, unhandled errors in component setup or rendering are suppressed and logged to console by default, causing renderToString to resolve with partial markup unless app.config.throwUnhandledErrorInProduction is set to true.","Enabling app.config.throwUnhandledErrorInProduction causes renderToString to reject synchronously with the thrown setup or render error.","Setting app.config.errorHandler intercepts the error before the production error-logging path, receiving the minified runtime error URL as its info parameter."],"goal":"Configure Vue 3 SSR error bubbling in production using throwUnhandledErrorInProduction to prevent silent promise resolution on unhandled component errors","kind":"HOW","packages":["pkg:npm/vue@3.5.41"],"schemaVersion":1,"symbols":["createSSRApp","app.config.throwUnhandledErrorInProduction","app.config.errorHandler"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","executionContext":"node","language":"node","os":"linux","packageManager":"npm","runtime":"node","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/vue@3.5.41"],"schemaVersion":1,"symbols":["createSSRApp","app.config.throwUnhandledErrorInProduction","app.config.errorHandler"],"verifierAdapter":"node-typescript@1"}
{
"name": "npm-vue-config",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "npm-vue-config",
"version": "1.0.0",
"dependencies": {
"vue": "3.5.41"
}
},
"node_modules/@babel/helper-string-parser": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz",
"integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/helper-validator-identifier": {
"version": "7.29.7",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",
"integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",
"license": "MIT",
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@babel/parser": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.8.tgz",
"integrity": "sha512-E8lTAYNB1KW+FH+VGJuZM1ioAx2E6oVlvQFRrf5P8ZZmsiJXYAD9vTFV7yyEURNzgh1dFqMZuO6tUwcARbqFCA==",
"license": "MIT",
"dependencies": {
"@babel/types": "^7.29.8"
},
"bin": {
"parser": "bin/babel-parser.js"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/@babel/types": {
"version": "7.29.8",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz",
"integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==",
"license": "MIT",
"dependencies": {
"@babel/helper-string-parser": "^7.29.7",
"@babel/helper-validator-identifier": "^7.29.7"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@jridgewell/sourcemap-codec": {
"version": "1.5.5",
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
"license": "MIT"
},
"node_modules/@vue/compiler-core": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/compiler-core/-/compiler-core-3.5.41.tgz",
"integrity": "sha512-q0Xtv/F9w2YO/7htQhtiL+Ev2WCJbe5N2hc+XfgyKkEKqWpSxknmT8QOuGdEKNdjPq0c3F7rNpFkTo3Kfrm7pg==",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.29.8",
"@vue/shared": "3.5.41",
"entities": "^7.0.1",
"estree-walker": "^2.0.2",
"source-map-js": "^1.2.1"
}
},
"node_modules/@vue/compiler-dom": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/compiler-dom/-/compiler-dom-3.5.41.tgz",
"integrity": "sha512-oKacVfNglLvGjnS6BXOlGL7EyG2h8X03pqXCjzotRZUaXGjbrTJUnVAQjrCqUnS+lyu31nwQjZY/d817GmCnfw==",
"license": "MIT",
"dependencies": {
"@vue/compiler-core": "3.5.41",
"@vue/shared": "3.5.41"
}
},
"node_modules/@vue/compiler-sfc": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-3.5.41.tgz",
"integrity": "sha512-XJhip7R2wy6vX3knCxdZN4KracFaZUef58s1KYewqluedHIJaPIVfXoYT7MF1F8nCvv6k8bWWxDC8opMkg1VTQ==",
"license": "MIT",
"dependencies": {
"@babel/parser": "^7.29.8",
"@vue/compiler-core": "3.5.41",
"@vue/compiler-dom": "3.5.41",
"@vue/compiler-ssr": "3.5.41",
"@vue/shared": "3.5.41",
"estree-walker": "^2.0.2",
"magic-string": "^0.30.21",
"postcss": "^8.5.19",
"source-map-js": "^1.2.1"
}
},
"node_modules/@vue/compiler-ssr": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/compiler-ssr/-/compiler-ssr-3.5.41.tgz",
"integrity": "sha512-U3v5OejKEGqOI0Wy0+Sz7hGuIFZHA4LSXzrNM3IMIeDyJEBBfTpX26n3SDgToRpP2bLc9FfI2j/kSgcJ8Emq5A==",
"license": "MIT",
"dependencies": {
"@vue/compiler-dom": "3.5.41",
"@vue/shared": "3.5.41"
}
},
"node_modules/@vue/reactivity": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/reactivity/-/reactivity-3.5.41.tgz",
"integrity": "sha512-rznsqKM0np0x18EjzF8x88MpEhdNsffbvFbckLL5+oUKz1BxAImEmO7J1ArRYSyo6aQaVoBDp7jEkT91OOxydA==",
"license": "MIT",
"dependencies": {
"@vue/shared": "3.5.41"
}
},
"node_modules/@vue/runtime-core": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/runtime-core/-/runtime-core-3.5.41.tgz",
"integrity": "sha512-Vcry58hiAKwGen9Z1jUZE0feFsNArPCMOImYI8el48A9Idf6DuQYD0U05zZIF2Iad1hGhPSvcbBbAOhNr55fhg==",
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.5.41",
"@vue/shared": "3.5.41"
}
},
"node_modules/@vue/runtime-dom": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/runtime-dom/-/runtime-dom-3.5.41.tgz",
"integrity": "sha512-3vVBahVBS9+U6cmXBLyb8nE6/yYo4J/CGI9eVFs3KiMc0YHuudwKyShTD65jtJy/L9PUUxNAFu4cj4LiJ0UFbw==",
"license": "MIT",
"dependencies": {
"@vue/reactivity": "3.5.41",
"@vue/runtime-core": "3.5.41",
"@vue/shared": "3.5.41",
"csstype": "^3.2.3"
}
},
"node_modules/@vue/server-renderer": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/server-renderer/-/server-renderer-3.5.41.tgz",
"integrity": "sha512-n6hx/pNFfbD6SuyeuMVkvqox8bwf/ET9JlA/kAz/imw8sw++wkqKe2mHX5KutjPpbKE4Z56yTHszoOjGMI9igQ==",
"license": "MIT",
"dependencies": {
"@vue/compiler-ssr": "3.5.41",
"@vue/runtime-dom": "3.5.41",
"@vue/shared": "3.5.41"
}
},
"node_modules/@vue/shared": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/@vue/shared/-/shared-3.5.41.tgz",
"integrity": "sha512-IOnwSCma8j+9xJT6b8H0dEYidC80NsYmNMlZxRsukYcSoGaDBohog5hDxzeUXdFeGWFA++vWvxqOmrr96VlqMA==",
"license": "MIT"
},
"node_modules/csstype": {
"version": "3.2.3",
"resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz",
"integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",
"license": "MIT"
},
"node_modules/entities": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/entities/-/entities-7.0.1.tgz",
"integrity": "sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=0.12"
},
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/estree-walker": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz",
"integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==",
"license": "MIT"
},
"node_modules/magic-string": {
"version": "0.30.21",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.5"
}
},
"node_modules/nanoid": {
"version": "3.3.18",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
"integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",
"license": "ISC"
},
"node_modules/postcss": {
"version": "8.5.26",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
"integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/postcss/"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/postcss"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
"dependencies": {
"nanoid": "^3.3.17",
"picocolors": "^1.1.1",
"source-map-js": "^1.2.1"
},
"engines": {
"node": "^10 || ^12 || >=14"
}
},
"node_modules/source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/vue": {
"version": "3.5.41",
"resolved": "https://registry.npmjs.org/vue/-/vue-3.5.41.tgz",
"integrity": "sha512-2laE0p+aK+/AOPG/XL/WepOs/GlK755LJ1XECi9kDUrz1FKNw8rb2Xzlw9JS1rqEV55nb0ttsKxVlTCcd+R5cg==",
"license": "MIT",
"dependencies": {
"@vue/compiler-dom": "3.5.41",
"@vue/compiler-sfc": "3.5.41",
"@vue/runtime-dom": "3.5.41",
"@vue/server-renderer": "3.5.41",
"@vue/shared": "3.5.41"
},
"peerDependencies": {
"typescript": "*"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
}
}
}
{
"name": "npm-vue-config",
"version": "1.0.0",
"type": "module",
"dependencies": {
"vue": "3.5.41"
}
}
import assert from 'node:assert';
// Set NODE_ENV to production before loading Vue to exercise production error handling
process.env.NODE_ENV = 'production';
const { createSSRApp } = await import('vue');
const { renderToString } = await import('vue/server-renderer');
// Helper to suppress console.error during tests expecting unhandled errors
function silentConsoleError(fn) {
const originalError = console.error;
console.error = () => {};
try {
return fn();
} finally {
console.error = originalError;
}
}
// 1. In production mode without throwUnhandledErrorInProduction (default),
// unhandled component setup errors are caught internally and logged to console,
// allowing renderToString to resolve with partial markup instead of rejecting.
{
const app = createSSRApp({
setup() {
throw new Error('Component setup failed in production');
},
template: '<div>Unreachable Markup</div>'
});
assert.strictEqual(app.config.throwUnhandledErrorInProduction, undefined);
let resolved = false;
let html = '';
await silentConsoleError(async () => {
try {
html = await renderToString(app);
resolved = true;
} catch {
resolved = false;
}
});
assert.strictEqual(resolved, true, 'Default production SSR should resolve rather than reject on unhandled setup error');
assert.strictEqual(html, '<div>Unreachable Markup</div>');
}
// 2. When app.config.throwUnhandledErrorInProduction is set to true,
// unhandled setup errors re-throw in production, causing renderToString to reject.
{
const app = createSSRApp({
setup() {
throw new Error('Component setup failed with throwUnhandledErrorInProduction');
},
template: '<div>Unreachable Markup</div>'
});
app.config.throwUnhandledErrorInProduction = true;
let caughtError = null;
await silentConsoleError(async () => {
try {
await renderToString(app);
} catch (err) {
caughtError = err;
}
});
assert.notStrictEqual(caughtError, null, 'SSR should reject when throwUnhandledErrorInProduction is enabled');
assert.strictEqual(caughtError.message, 'Component setup failed with throwUnhandledErrorInProduction');
}
// 3. When app.config.throwUnhandledErrorInProduction is true,
// render function errors also cause renderToString to reject.
{
const app = createSSRApp({
render() {
throw new Error('Component render failed in production');
}
});
app.config.throwUnhandledErrorInProduction = true;
let caughtError = null;
await silentConsoleError(async () => {
try {
await renderToString(app);
} catch (err) {
caughtError = err;
}
});
assert.notStrictEqual(caughtError, null, 'SSR should reject on render function error with throwUnhandledErrorInProduction=true');
assert.strictEqual(caughtError.message, 'Component render failed in production');
}
// 4. Configuring app.config.errorHandler intercepts errors before default logging,
// receiving the error instance, component proxy, and minified production error info URL.
{
const app = createSSRApp({
setup() {
throw new Error('Component setup error routed to errorHandler');
},
template: '<div>Handled Markup</div>'
});
const handledErrors = [];
app.config.errorHandler = (err, instance, info) => {
handledErrors.push({
message: err.message,
info,
hasInstance: !!instance
});
};
const html = await renderToString(app);
assert.strictEqual(html, '<div>Handled Markup</div>');
assert.strictEqual(handledErrors.length, 1);
assert.strictEqual(handledErrors[0].message, 'Component setup error routed to errorHandler');
assert.strictEqual(handledErrors[0].info, 'https://vuejs.org/error-reference/#runtime-0');
assert.strictEqual(handledErrors[0].hasInstance, true);
}