jobbrIO / jobbr-server

Jobbr is a non-invasive .NET JobServer
https://jobbr.readthedocs.io
GNU General Public License v3.0
50 stars 5 forks source link

JobbrServer is instantiated four times #102

Closed eXpl0it3r closed 1 year ago

eXpl0it3r commented 1 year ago

Steps to Reproduce

  1. Start the Demo app

Actual Behavior

The JobbrServer constructor is called four times. Which also means if you trigger a job in the UI, four job runs are added.

Expected Behavior

The JobbrServer is only instantiated once and creating triggers doesn't cause a quadruplication of job runs.

Additional Information

eXpl0it3r commented 1 year ago

The issue was that the JobbrServer was added to the DI container to more easily resolve its dependencies, this then however lead to the BackChannelWebHost creating a new instance for every sub-component and consequently the duplication of the message dispatching subscriptions.

https://github.com/jobbrIO/jobbr-server/blob/5e2722f5c663ac1592194cd02fa839420ab1d0a0/source/Jobbr.Server/Builder/JobbrBuilder.cs#L41

While the manual instantiation now works, it begs the question, whether there's something fundamentally broken with the new DI / WebHost setup. Not necessarily because of SimpleInjector, but because of the mixing between Microsoft Service DI and SimpleInjector registrations. For now, I can't detect any other issues, but might keep a closer eye on this.

eXpl0it3r commented 1 year ago

Fixed with 396a8566acc129ef27a559ceb686736bc3921a29