question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Delayed plugin initialisation

See original GitHub issue

Hey,

First of all, thanks for all the efforts on this, I like deno_mongo very much 😃

Now, here’s about the issue I’m encountering. I am trying to lazy-load deno_mongo for my project denodb which handles different types of databases. The problem being that if someone only wants to use mysql, the library shouldn’t load mongodb (which comes with additional command flags unstable and allow-plugin at least).

After digging in the code, I found a solution to lazy-load everything:

const { MongoClient, RELEASE_URL, init } = await import("../../unstable_deps.ts");
await init(RELEASE_URL);
const client = new MongoClient();

But obviously this is when I realised, this is already being done in mod.ts. The problem is, when lazy-loaded, the module doesn’t wait on the await init(...) instruction from that file.

Uncaught Error: The plugin must be initialized before use

So far, the only solution I found was to remove that line (with init) from my local package mod.ts. Otherwise, by keeping my additional await init(...), I am getting an error saying that I am trying to initialise the same plugin twice (which makes sense).

I am therefore asking: could something be done here so that this library could be lazy-loaded when necessary? I know this might only be my problem right now, but I am sure it might be someone else’s someday.

Just let me know if you could do something about this, any thought.

Thanks for your time and keep up the good work 😃

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
manyuanrongcommented, Nov 27, 2020

The project was rewritten using TS. This will no longer be a issue

1reaction
manyuanrongcommented, Jun 17, 2020

At the beginning, init was not included in mod.ts, until many people forgot to call init before using it, it exists in mod.ts.

One of the solutions is to use dynamic import to load the deno_mongo library in your integrated library

Read more comments on GitHub >

github_iconTop Results From Across the Web

Method: Delayed::Plugin#initialize — Documentation for ...
Method: Delayed::Plugin#initialize. Defined in: lib/delayed/plugin.rb. permalink #initialize ⇒ Plugin. Returns a new instance of Plugin. [View source] ...
Read more >
Lazy plugin initialization and/or plugin initialization delayed?
Hi,. I would say I read somewhere there was a parameter supported in the atlassian-plugin.xml to delay plugin initialization until Jira is ...
Read more >
RabbitMQ Delayed Message Plugin - GitHub
This plugin adds delayed-messaging (or scheduled-messaging) to RabbitMQ. A user can declare an exchange with the type x-delayed-message and then publish ...
Read more >
Late initialization - WordPress.org
Hello, I'm trying to develop a plugin catching referer domains and places. Without WP Fastest Cache, my plugin works perfectly but when I...
Read more >
Startup Delays - initializing plugins - General X-Plane Forum
Recently when I start up XP it displays a message saying "will initialize plugins" and then takes a number of minutes rot do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found