jovotech/jovo-framework

Using AskForPermissionConsentCardOutput throws error

Closed this issue · 2 comments

I'm submitting a...

  • Bug report
  • Feature request
  • Documentation issue or request
  • Other... Please describe:

Expected Behavior

Using AskForPermissionConsentCardOutput throws error of "Cannot redefine property: $alexa".

Current Behavior

import { AskForPermissionConsentCardOutput } from '@jovotech/platform-alexa';
import { BaseComponent, Component } from '@jovotech/framework';

@Component()
export class SampleComponent extends BaseComponent {
    public async someHandler(): Promise<void> {
        try {
            const email = await this.$alexa?.$user?.getEmail();
            return await this.$send({ message: `this is your email: ${email}` });
        } catch (error) {
            return this.$send(AskForPermissionConsentCardOutput, {
                message: 'Please grant the permission to access your email',
                permissions: ['alexa::profile:email:read'],
            });
        }
    }
}

Error Log

TypeError: Cannot redefine property: $alexa
    at Function.defineProperty (<anonymous>)
    at registerPlatformSpecificJovoReference (/workspace/node_modules/.pnpm/@jovotech+framework@4.2.15/node_modules/@jovotech/framework/src/Jovo.ts:89:10)
    at Object.<anonymous> (/workspace/node_modules/.pnpm/@jovotech+platform-alexa@4.2.15_898c6511b54b18b3c59ef204ea1e3f98/node_modules/@jovotech/platform-alexa/src/index.ts:22:38)

Your Environment

  • Jovo Framework version used: 4.2.14
  • Operating System: Mac OS (M1)
  • Node: 16.13.0
  • Jest: ^27.3.1

Hi @weisslertal,

Thank you for the detailed issue. I couldn't reproduce it in MacOS:

image

When does the error occur? When you run jovo run or when the request is entering the webhook?

Would it be possible for you to create a repo with a minimum project to help us reproduce this issue? Thanks!

Closing this because it was due to a dependency conflict