Skip to content

vue-router: TypeError: Cannot read properties of undefined (reading '__vccOpts') #14080

Closed as not planned

Description

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.35.0

Framework Version

Vue 8.35.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

I have a Vue 3 (3.5.4) application using vue-router (4.4.3) and with SSR environment. In the Vue app I use @sentry/vue (8.35.0) and for production I use express node server.

Vue package.json

{
  "scripts": {
    ...
    "server:run": "NODE_ENV=production node --import ./server/instrument.js server"
  }
} 

server/instrument.js

import * as Sentry from '@sentry/node'

Sentry.init({
  dsn: process.env.DSN,
  tracesSampleRate: 1.0,
  profilesSampleRate: 1.0,
})

server/index.js

import * as Sentry from '@sentry/node'
...
const { default: renderPage } = await import(path.join(root, 'dist/server/main.js')) /* Vue server client app. */
...
app.use('*', async (request, response) => {
  try {
    ...
    const { html, status, statusText, headers } = await renderPage(url, {
      manifest,
      preload: true,
      request,
      response,
    })
    ...
})
...
Sentry.setupExpressErrorHandler(app)
...
app.listen(port)

After run the server with yarn server:run I get the following error on first server call. The node server crashes completely.

TypeError: Cannot read properties of undefined (reading '__vccOpts')
    at file:///.../node_modules/vue-router/dist/vue-router.mjs:2172:55
TypeError: Cannot read properties of undefined (reading '__vccOpts')
    at file:///.../node_modules/vue-router/dist/vue-router.mjs:2172:55
file:///.../node_modules/vue-router/dist/vue-router.mjs:2172
                    const options = resolvedComponent.__vccOpts || resolvedComponent;

router/index.js

import { RouterView } from 'vue-router'
import { asyncLoadRouter } from '@common/helpers'

export default [
  {
    path: '/',
    component: RouterView,
    children: [
      {
        path: '',
        component: asyncLoadRouter('WrapperHome'),
        children: [
          {
            path: '',
            name: 'home',
            component: asyncLoadRouter('wrapper/Home'),
          },
        ],
      }
    ],
  },
]

Steps to Reproduce

  1. Build Vue app with vite
  2. Run yarn server:run
  3. Open application in browser
  4. Error is thrown.
    Removing --import ./server/instrument.js from server:run script, the error is not thrown.

Expected Result

The server should run without throwing this error, like before adding @sentry/node code. If I use only @sentry/vue in the Vue app, all works fine. Adding @sentry/node to express server script causes node server crash.

Is there also a way to isolate @sentry/node import on express server from @sentry/vue in Vue app?

Actual Result

After run the server with yarn server:run I get the following error on first server call. The node server crashes completely.

node server log

TypeError: Cannot read properties of undefined (reading '__vccOpts')
    at file:///.../node_modules/vue-router/dist/vue-router.mjs:2172:55
TypeError: Cannot read properties of undefined (reading '__vccOpts')
    at file:///.../node_modules/vue-router/dist/vue-router.mjs:2172:55
file:///.../node_modules/vue-router/dist/vue-router.mjs:2172
                    const options = resolvedComponent.__vccOpts || resolvedComponent;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Package: nodeIssues related to the Sentry Node SDKPackage: vueIssues related to the Sentry Vue SDKStale

    Type

    Projects

    • Status

      Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions