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

Intermittent "i.replaceAll is not a function" error on UButton and UBadge #2677

Open
maximepvrt opened this issue Nov 18, 2024 · 0 comments
Open
Labels
bug Something isn't working triage

Comments

@maximepvrt
Copy link
Contributor

maximepvrt commented Nov 18, 2024

Environment



Version

2.19.2

Reproduction

x

Description

I occasionally encounter the error i.replaceAll is not a function on a page using @nuxt/ui. The issue happens sporadically, and I cannot identify a consistent trigger. I discovered this problem via Sentry in production.

The page where this occurs is based on the following template @nuxt/ui-pro:
https://github.com/nuxt-ui-pro/saas/blob/main/app/pages/blog/%5Bslug%5D.vue

Image

Image

Additional context

<script setup lang="ts">
import { withoutTrailingSlash } from 'ufo'

const route = useRoute()

const { data: post } = await useAsyncData(route.path, () => queryContent(route.path).findOne(), {transform: p => {
    p.authors = (p.authors ?? []).map((a) => {
      return {...a, avatar: {src: `/team/${a.slug}.jpg`}}
    })
    return p
  }})
if (!post.value) {
  throw createError({ statusCode: 404, fatal: true })
}

const { data: surround } = await useAsyncData(`${route.path}-surround`, () => queryContent('/ressources')
        .where({ _extension: 'md' })
        .without(['body', 'excerpt'])
        .sort({ date: -1 })
        .findSurround(withoutTrailingSlash(route.path))
    , { default: () => [] })

useSeoMeta({
  title: post.value.title ?? null,
  description: post.value.description ?? null,
})

</script>

<template>
  <UContainer v-if="post">
    <UPageHeader
        :title="post.title"
        :description="post.description"
    >
      <template #headline>
        <UBadge
            v-bind="{label: post.category}"
            variant="subtle"
        />
        <span class="text-gray-500 dark:text-gray-400">&middot;</span>
        <time class="text-gray-500 dark:text-gray-400">{{ new Date(post.date).toLocaleDateString('fr', { year: 'numeric', month: 'short', day: 'numeric' }) }}</time>
        <span class="text-gray-500 dark:text-gray-400">&middot;</span>
        <span class="text-gray-500 dark:text-gray-400">{{post.readingTime > 1 ? `${post.readingTime} mins de lecture` : '1 min de lecture' }}</span>
      </template>
      <div class="flex flex-wrap items-center gap-3 mt-4">
        <UButton
            v-for="(author, index) in post.authors"
            :key="index"
            color="white"
            target="_blank"
            size="sm"
        >
          <UAvatar
              v-bind="author.avatar"
              :alt="author.name"
              size="2xs"
          />

          {{ author.name }}
        </UButton>
      </div>
    </UPageHeader>

    <UPage>
      <UPageBody prose>
        <ContentRenderer
            v-if="post && post.body"
            :value="post"
        />

        <hr v-if="surround?.length" />

        <UContentSurround :surround="surround" />
      </UPageBody>

      <template #right>
        <UContentToc
            v-if="post.body && post.body.toc"
            :links="post.body.toc.links"
            title="Sommaire"
        />
      </template>
    </UPage>
  </UContainer>
</template>

Logs

@maximepvrt maximepvrt added bug Something isn't working triage labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

1 participant