capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

bug: TypeError: undefined is not a constructor (evaluating 'new cap.Exception('')')

Open Badisi opened this issue 2 years ago • 2 comments

Bug Report

Capacitor Version

  @capacitor/cli: 3.6.0
  @capacitor/core: 3.6.0
  @capacitor/android: 3.6.0
  @capacitor/ios: 3.6.0

Current Behavior

I have installed a plugin that should throw an error but failed at it because cap.Exception is undefined.

TypeError: undefined is not a constructor (evaluating 'new cap.Exception('')') @capacitor/ios#native-bridge.js#L406

After some investigation I found out that cap.Exception is set in createCapacitor() of @capacitor/core.

So I added the following to my application and the error disappeared :

import '@capacitor/core';

Expected Behavior

I don't know whether this should be considered as a bug or not, but it certainly was not trivial to find.

I had npm installed the @capacitor/core package but did not imported it as I don't needed it. So in this particular case, should I be the one to import it ? or should it be the plugin somehow ? to make sure it is not forgotten.

Can you guys please give me your thoughts on this ? Thanks!

Code reproduction

  1. Checkout https://github.com/Badisi/capacitor-exception-issue
  2. npm install
  3. npx cap run ios
  4. Inspect the simulator through a web console

Other Technical Details

npm --version output: 8.13.2 node --version output: v16.14.2 pod --version output (iOS issues only): 1.11.2

Badisi avatar Jul 11 '22 12:07 Badisi

This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue.

Please see the Contributing Guide for how to create a Code Reproduction.

Thanks! Ionitron 💙

Ionitron avatar Jul 11 '22 13:07 Ionitron

@jcesarmobile, I have added a code reproduction section, thanks.

Badisi avatar Jul 11 '22 13:07 Badisi

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Nov 10 '22 18:11 ionitron-bot[bot]