diff --git a/src/server/create-bundle-renderer.js b/src/server/create-bundle-renderer.js index 3f8859bf..3fb630e9 100644 --- a/src/server/create-bundle-renderer.js +++ b/src/server/create-bundle-renderer.js @@ -8,12 +8,16 @@ export function createBundleRendererCreator (createRenderer) { renderToString: (context, cb) => { runInVm(code, context).then(app => { renderer.renderToString(app, cb) - }) + }).catch(cb) }, renderToStream: (context) => { const res = new PassThrough() runInVm(code, context).then(app => { renderer.renderToStream(app).pipe(res) + }).catch(err => { + process.nextTick(() => { + res.emit('error', err) + }) }) return res } diff --git a/src/server/run-in-vm.js b/src/server/run-in-vm.js index ded8c03b..ac78daf6 100644 --- a/src/server/run-in-vm.js +++ b/src/server/run-in-vm.js @@ -30,8 +30,6 @@ export default function runInVm (code, _context) { const res = Object.prototype.hasOwnProperty.call(m.exports, 'default') ? m.exports.default : m - if (typeof res.then !== 'function') { - throw new Error('SSR bundle should export a Promise.') - } - return res + // ensure returning a Promise + return Promise.resolve(res) }