Skip to content

Commit 42c5e22

Browse files
committed
fix: use lifecycle instead of beforeStart
1 parent 41fe40f commit 42c5e22

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/egg.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ export class EggCore extends KoaApplication {
239239
const singleton = new Singleton(options);
240240
const initPromise = singleton.init();
241241
if (initPromise) {
242-
this.beforeStart(async () => {
242+
this.lifecycle.registerBeforeStart(async () => {
243243
await initPromise;
244-
});
244+
}, `${name}-singleton-init`);
245245
}
246246
}
247247

src/singleton.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export class Singleton<T = any> {
108108
createInstance(config: Record<string, any>, clientName: string) {
109109
// async creator only support createInstanceAsync
110110
assert(!isAsyncFunction(this.create),
111-
`[@eggjs/core/singleton] ${this.name} only support synchronous creation, please use createInstanceAsync`);
111+
`[@eggjs/core/singleton] ${this.name} only support asynchronous creation, please use createInstanceAsync`);
112112
// options.default will be merge in to options.clients[id]
113113
config = {
114114
...this.options.default,

0 commit comments

Comments
 (0)