ServiceProvider's bootWhen method with serviceProvider arg always being undefined #4524
-
I wish my plugin to boot after a specific serviceProvider, but serviceProvider is always Code sample: export class ServiceProvider extends Providers.ServiceProvider {
@Container.inject(Container.Identifiers.LogService)
private readonly logger!: Contracts.Kernel.Logger;
public async register(): Promise<void> {
// this gets called when core starts
}
public async boot(): Promise<void> {
}
public async bootWhen(serviceProvider?: string): Promise<boolean> {
// serviceProvider is always `undefined`
return !!this.config().get("enabled") && serviceProvider === "@arkecosystem/core-blockchain";
}
public async dispose(): Promise<void> {
}
} Strange thing is I didn't notice this issue when installing from source and running testnet on my local computer. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Can you try adding |
Beta Was this translation helpful? Give feedback.
-
I suspect that you changed the plugin order in app.json file. Can you check that? Generally you don't need to wait to specific serviceProvider to be booted. The boot process will boot them in the same order as they are provided in app.json. It is possible that you located your plugin after the Approach when your plugin depends on another serviceProvider is recommended when dependent plugin is disposed and then booted again, but not on the initial boot. |
Beta Was this translation helpful? Give feedback.
I suspect that you changed the plugin order in app.json file. Can you check that?
Generally you don't need to wait to specific serviceProvider to be booted. The boot process will boot them in the same order as they are provided in app.json.
It is possible that you located your plugin after the
@arkecosystem/core-blockchain
and this mean that core-blockchain is booted before the handler for your plugin is registered, which results in a missing event, where serviceProvider variable should be equal@arkecosystem/core-blockchain
.Approach when your plugin depends on another serviceProvider is recommended when dependent plugin is disposed and then booted again, but not on the initial boot.