Provide access to the DI container for plugin providers

Some clients like ‘nats’ are supposed to work with a singleton connection instance.
To open one connection per workflow(trigger) does not scale.

n8n uses internally the DI pattern to create and query singleton service instances
with the help of ‘typedi’

But usage of the main ‘typedi’ container seams scoped inside the plugin-workflow.

n8n need to provide the possibility for plugins to register, host and query
global singletons from the DI container

My try on it, it creates singleton connection for a single workflow,
but not a singleton per credential instance

Reference issue:

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

This is not a bug/issue report, but to make the n8n bot happy
n8n version: 1.27.2
Database (default: SQLite): postgres
n8n EXECUTIONS_PROCESS setting (default: own, main): default
Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
Operating system: linux32-64

Perhaps @marcus from our node engineering team can shed some light on this one?

Still unresolved.

My code works fine, but it creates singletons for each workflow instance.

Most likely the workflows instances are created in executed in some kind sandbox environment of nodejs and I am no expert in nodejs features.