Skip to content

Commit

Permalink
fix(core): fix service api causing memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 21, 2022
1 parent 3076bfc commit aeacedb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ export class Context {
if (!plugin) throw new Error('root level context cannot be disposed')
const state = this.app.registry.get(plugin)
if (!state) return
await Promise.allSettled([
const task = Promise.allSettled([
...state.children.slice().map(plugin => this.dispose(plugin)),
...state.disposables.slice().map(dispose => dispose()),
]).finally(() => {
this.app.registry.delete(plugin)
remove(state.parent.children, plugin)
this.emit('plugin-removed', plugin)
})
])
this.app.registry.delete(plugin)
remove(state.parent.children, plugin)
this.emit('plugin-removed', plugin)
await task
}

* getHooks(name: EventName, session?: Session) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export abstract class Service {
}

get caller(): Context {
return this.ctx[Context.current] || this.ctx
return this[Context.current] || this.ctx
}
}

Expand Down

0 comments on commit aeacedb

Please sign in to comment.