Open
Description
When I deploy the following to Cloudflare Pages I get the 500 error cannot read properties of null (reading 'ce')
during SRR. I'm using Nuxt.
SanityLink.vue
<script setup lang="ts">
// Props
const props = defineProps<{
href?: string;
}>();
</script>
<template>
<NuxtLink :to="href">
<slot />
</NuxtLink>
</template>
SanityRichText.vue
<script setup lang="ts">
// Types
import type { PortableTextBlock } from "@portabletext/types";
import type { PortableTextMarkComponentProps } from "@portabletext/vue";
import { PortableText } from "@portabletext/vue";
// Explicit component imports
import LazySanityLink from "./SanityLink.vue";
// Props
defineProps({
content: {
type: Array<PortableTextBlock>,
required: true,
},
});
// Custom components
const components = {
marks: {
link: (props: PortableTextMarkComponentProps, { slots }: any) => {
return h(
// Pass the component
LazySanityLink,
// Pass individual props
{ href: props.value?.href },
// Pass children slots
slots
);
},
},
};
</script>
<template>
<div>
<PortableText :value="content" :components />
</div>
</template>
Here's what I know from my troubleshooting:
- The issue occurs on Cloudflare Pages during SSR/hydration. It works fine during client side navigation and locally during dev.
- It's specific to a
SanityLink.vue
when it renders dynamic content via<slot />
. - Hardcoding
'test'
inside theSanityLink.vue
instead of using<slot />
works. - Wrapping the
<slot />
in<ClientOnly>
insideSanityLink.vue
works. - Using
SanityLink
instead ofLazySanityLink
doesn't make a difference.
Other causes of this error include mismatched Vue versions which I've already checked for. I've already spent many hours on this.
On a related note, when I use slots.default?.()
instead of slots
in my SanityRichText.vue
component (as per the docs, I get a Vue console error: [Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.
.
Metadata
Metadata
Assignees
Labels
No labels