Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(runtime-core): only set cache for object keys #6266

Merged
merged 2 commits into from Aug 29, 2022

Conversation

danielroe
Copy link
Member

Background

On SSR if an unregistered component is used we have a hard crash as we try to cache the details about this component, but it's a string (not a resolved object) and can't be used as a cache key to the WeakMap that's we're using.

It's true this is wrong usage, and there is a helpful warning:

[Vue warn]: Failed to resolve component: SomeThing
If this is a native custom element, make sure to exclude it from component resolution via compilerOptions.isCustomElement.

But there is also a fatal and hard error that occurs:

Fatal error:

Error: WeakMap key must be an object, got comp
    at _evaluate (https://node-2lafe5-dfi279td.w-corp.staticblitz.com/blitz.bff91798029e1af88e01551d056a592b2882b9ac.js:15:286611)
    at <anonymous> (<anonymous>)

Code

import { createSSRApp } from 'vue';
import { renderToString } from 'vue/server-renderer';

const app = createSSRApp({
  template: `<SomeThing />`,
});

console.log(await renderToString(app));

https://stackblitz.com/edit/node-2lafe5?file=index.mjs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants