Meituan-Dianping/mpvue · error · Error

createStream cannot be called without a template.

Error message

createStream cannot be called without a template.

What it means

Generic guard thrown by TemplateRenderer.createStream when parsedTemplate is undefined, i.e. the renderer was built without a template. Streaming interpolation requires a parsed HTML template with the content placeholder; calling createStream on a template-less renderer cannot work.

Source

Thrown at src/server/template-renderer/index.js:229

      return needed.filter(isJS).map(file => {
        return `<script src="${this.publicPath}/${file}" defer></script>`
      }).join('')
    } else {
      return ''
    }
  }

  getUsedAsyncFiles (context: Object): ?Array<string> {
    if (!context._mappedFiles && context._registeredComponents && this.mapFiles) {
      context._mappedFiles = this.mapFiles(Array.from(context._registeredComponents))
    }
    return context._mappedFiles
  }

  // create a transform stream
  createStream (context: ?Object): TemplateStream {
    if (!this.parsedTemplate) {
      throw new Error('createStream cannot be called without a template.')
    }
    return new TemplateStream(this, this.parsedTemplate, context || {})
  }
}

function getPreloadType (ext: string): string {
  if (ext === 'js') {
    return 'script'
  } else if (ext === 'css') {
    return 'style'
  } else if (/jpe?g|png|svg|gif|webp|ico/.test(ext)) {
    return 'image'
  } else if (/woff2?|ttf|otf|eot/.test(ext)) {
    return 'font'
  } else {
    // not exhausting all possbilities here, but above covers common cases
    return ''
  }

View on GitHub (pinned to 6c5d78ee04)

Solutions

  1. Create the renderer with a template: createBundleRenderer(bundle, { template })
  2. Use renderer.renderToStream without a TemplateRenderer if no template is needed
  3. Check that the template file loaded successfully before constructing the renderer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/server/template-renderer/index.js:229 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Meituan-Dianping/mpvue@6c5d78ee04 (2026-09-02). Data as JSON: /api/errors/1c4ce4a05c448097. Report an issue: GitHub.