You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a web plugin is used without await, multiple instances get created, which causes problems for addListener calls.
See ionic-team/capacitor-plugins#1699 for more details.
If not using await on the plugin calls, the plugin's registerPlugin function gets executed multiple times, and the way we have created the plugins a new plugin gets created every time.
Note that the web's registerPlugin doesn't get executed multiple times, the plugin is only registered once on web as expected and it already has a "singleton" like mechanism that would return an existing plugin if it was already created, but the plugin's registerPlugin multiple executions don't result in multiples web runtime registerPlugin calls.
Additional Context
While this could be fixed plugin by plugin (like the proposed "singleton" in the linked issue or creating the web plugin outside of the registerPlugin call so it always returns the same, I think we should try to fix it in @capacitor/core so it get fixed for all plugins without additional changes on them.
The text was updated successfully, but these errors were encountered:
This issue has been labeled as type: bug. This label is added to issues that that have been reproduced and are being tracked in our internal issue tracker.
Bug Report
Capacitor Version
5.x
Platform(s)
web
Current Behavior
If a web plugin is used without await, multiple instances get created, which causes problems for
addListener
calls.See ionic-team/capacitor-plugins#1699 for more details.
Expected Behavior
A single instance of the plugin should be created
Code Reproduction
https://github.com/miqmago/capacitor-plugins-issue-1699
Other Technical Details
If not using await on the plugin calls, the plugin's
registerPlugin
function gets executed multiple times, and the way we have created the plugins a new plugin gets created every time.Note that the web's
registerPlugin
doesn't get executed multiple times, the plugin is only registered once on web as expected and it already has a "singleton" like mechanism that would return an existing plugin if it was already created, but the plugin'sregisterPlugin
multiple executions don't result in multiples web runtimeregisterPlugin
calls.Additional Context
While this could be fixed plugin by plugin (like the proposed "singleton" in the linked issue or creating the web plugin outside of the
registerPlugin
call so it always returns the same, I think we should try to fix it in@capacitor/core
so it get fixed for all plugins without additional changes on them.The text was updated successfully, but these errors were encountered: