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

Supporting routes with layout and different props was broken #44

Open
2 tasks done
SuslegStyle opened this issue Nov 15, 2021 · 0 comments
Open
2 tasks done

Supporting routes with layout and different props was broken #44

SuslegStyle opened this issue Nov 15, 2021 · 0 comments

Comments

@SuslegStyle
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the regression has not already been reported

Last working version

2.2.0-beta.2

Stopped working in version

2.2.3

Node.js version

14.18.1

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

Windows 10

💥 Regression Report

Hi There.

My test example is placed here (https://github.com/SuslegStyle/fastify-vite-hello-world)
Let me describe my use case.

I have a custom routes.js file where I define routes like

export default () => [
    {
        path: '/',
        component: Layout,
        props: {testProperty: 'Hello world'},
        children: [
            {
                path: '',
                component: Index,

            }
        ]
    },
    {
        path: '/',
        component: Layout,
        props: {testProperty: 'Hello external world'},
        children: [
            {
                path: 'external/',
                component: Index //TODO: in real app it is another page component
            }
        ]
    }
];

I use props to pass correct value to layout. In the real app, the props value changes Header.
After upgrading to 2.2.3 I start getting error during the build
Method 'GET' already declared for route '/' with constraints '{}'

Steps to Reproduce

First issue

  1. Clone my example
  2. Run npm run build
internal/process/promises.js:213
        triggerUncaughtException(err, true /* fromPromise */);
        ^

AssertionError [ERR_ASSERTION]: Method 'GET' already declared for route '/' with constraints '{}'
    at Router._insert (D:\fastify-vite-hello-world\node_modules\find-my-way\index.js:303:7)
    at Router._on (D:\fastify-vite-hello-world\node_modules\find-my-way\index.js:231:8)
    at Router.on (D:\fastify-vite-hello-world\node_modules\find-my-way\index.js:100:8)
    at Object.afterRouteAdded (D:\fastify-vite-hello-world\node_modules\fastify\lib\route.js:254:16)
    at D:\fastify-vite-hello-world\node_modules\fastify\lib\route.js:181:25
    at Object._encapsulateThreeParam (D:\fastify-vite-hello-world\node_modules\avvio\boot.js:551:7)
    at Boot.timeoutCall (D:\fastify-vite-hello-world\node_modules\avvio\boot.js:447:5)
    at Boot.callWithCbOrNextTick (D:\fastify-vite-hello-world\node_modules\avvio\boot.js:428:19)
    at Boot._after (D:\fastify-vite-hello-world\node_modules\avvio\boot.js:273:26)
    at Plugin.exec (D:\fastify-vite-hello-world\node_modules\avvio\plugin.js:132:19) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

Second issue

There is a second issue, that start reproducing again.
If in my routes.js change line 18 to path: '/my', then we get the error

D:\fastify-vite-hello-world\node_modules\fastify-vite\build.js:25
  const outDir = vite.build.outDir || 'dist'
                      ^

TypeError: Cannot read property 'build' of null
    at build (D:\fastify-vite-hello-world\node_modules\fastify-vite\build.js:25:23)
    at Object.fastify.vite.ready (D:\fastify-vite-hello-world\node_modules\fastify-vite\index.js:208:13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async main (D:\fastify-vite-hello-world\server.js:30:5)

Third issue

I tried to change fastify-vite/build.js file at line 25
from const outDir = vite.build.outDir || 'dist'
to const outDir = vite?.build?.outDir || 'dist'

Then the application is built successfully, but I got the runtime error that appContext is null. (We already faced the issue before)

TypeError: Cannot read property 'appContext' of null
    at useGlobalProperties (/node_modules/fastify-vite-vue/client.mjs?v=e94165ef:133:30)
    at Module.useHydration (/node_modules/fastify-vite-vue/client.mjs?v=e94165ef:20:23)
    at setup (d:/fastify-vite-hello-world/pages/index.vue:8:24)
    at _sfc_main.setup (/pages/index.vue:48:23)
    at callWithErrorHandling (D:\fastify-vite-hello-world\node_modules\vue\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:6620:22)
    at setupStatefulComponent (D:\fastify-vite-hello-world\node_modules\vue\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:6246:29)
    at setupComponent (D:\fastify-vite-hello-world\node_modules\vue\node_modules\@vue\runtime-core\dist\runtime-core.cjs.js:6202:11)
    at renderComponentVNode (D:\fastify-vite-hello-world\node_modules\vue\node_modules\@vue\server-renderer\dist\server-renderer.cjs.js:198:17)
    at renderVNode (D:\fastify-vite-hello-world\node_modules\vue\node_modules\@vue\server-renderer\dist\server-renderer.cjs.js:304:22)
    at renderVNode (D:\fastify-vite-hello-world\node_modules\vue\node_modules\@vue\server-renderer\dist\server-renderer.cjs.js:310:17)

Expected Behavior

The application should be successfully built and works properly.

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

No branches or pull requests

1 participant