fix(cordis): make config reload transactional

This commit is contained in:
Tianyi Cui
2026-07-30 03:11:16 +08:00
parent f8eb6a9b84
commit 195f7fa9af
33 changed files with 1020 additions and 268 deletions
+1 -1
View File
@@ -334,7 +334,7 @@ export interface Events {
/** Interception hook for a service binding (no core producer). */
'internal/service'(this: Context, name: string, value: any): void
/** Waterfall: a fiber config update is being applied; skip `next()` to veto. */
'internal/update'(this: Fiber, config: any, noSave: boolean, next: () => void): void
'internal/update'(this: Fiber, config: any, noSave: boolean, next: () => void | Promise<void>): void | Promise<void>
/** Waterfall: a service is being read through the context proxy. */
'internal/get'(ctx: Context, name: string, error: Error, next: () => any): any
/** Waterfall: a service is being written through the context proxy. */
+3 -3
View File
@@ -728,13 +728,13 @@ export class Fiber {
*
* @param config — the new raw config; validated before anything restarts.
* @param noSave — hint for persistence hooks not to write the change back.
* @returns nothing; the restart runs behind the `internal/update` waterfall.
* @throws {ValidationError} when the new config fails validation.
* @returns the update waterfall result; the default restart returns a promise.
* @throws when validation, an update listener, or the restarted plugin fails.
*/
update(config: any, noSave = false) {
this.assertActive()
config = resolveConfig(this.runtime!, config)
this.context.waterfall(this, 'internal/update', config, noSave, () => {
return this.context.waterfall(this, 'internal/update', config, noSave, () => {
this.config = config
this._error = undefined
return this.restart()