fix: 错误处理时的ctx未被正确处理
This commit is contained in:
parent
e7053c46ef
commit
77f568fdff
|
|
@ -59,13 +59,15 @@ class AppLoader extends types_1.AppLoader {
|
|||
const errorToPublish = (0, lodash_1.cloneDeep)(err);
|
||||
await Promise.all(this.internalErrorHandlers.map((handler) => {
|
||||
return new Promise(async (resolve) => {
|
||||
const ctx = await this.makeContext();
|
||||
try {
|
||||
const ctx = await this.makeContext();
|
||||
console.log(`调用internalErrorHandler【${handler.name}】处理内部错误事件`);
|
||||
handler.handle(ctx, type, message, errorToPublish);
|
||||
await handler.handle(ctx, type, message, errorToPublish);
|
||||
await ctx.commit();
|
||||
}
|
||||
catch (e) {
|
||||
console.error('执行internalErrorHandler时出错', e);
|
||||
await ctx.rollback();
|
||||
}
|
||||
finally {
|
||||
resolve();
|
||||
|
|
@ -532,6 +534,7 @@ class AppLoader extends types_1.AppLoader {
|
|||
try {
|
||||
const result = await routineFn(context, {
|
||||
socket: this.nsSocket,
|
||||
contextBuilder: () => this.makeContext(),
|
||||
});
|
||||
console.log(`例程【${name}】执行成功,耗时${Date.now() - start}毫秒,结果是【${result}】`);
|
||||
await context.commit();
|
||||
|
|
@ -566,6 +569,7 @@ class AppLoader extends types_1.AppLoader {
|
|||
try {
|
||||
const result = await routineFn(context, {
|
||||
socket: this.nsSocket,
|
||||
contextBuilder: () => this.makeContext(),
|
||||
});
|
||||
console.log(`例程【${name}】执行成功,耗时${Date.now() - start}毫秒,结果是【${result}】`);
|
||||
await context.commit();
|
||||
|
|
|
|||
|
|
@ -70,12 +70,14 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Backe
|
|||
await Promise.all(this.internalErrorHandlers.map(
|
||||
(handler) => {
|
||||
return new Promise<void>(async (resolve) => {
|
||||
const ctx = await this.makeContext();
|
||||
try {
|
||||
const ctx = await this.makeContext();
|
||||
console.log(`调用internalErrorHandler【${handler.name}】处理内部错误事件`);
|
||||
handler.handle(ctx, type, message, errorToPublish);
|
||||
await handler.handle(ctx, type, message, errorToPublish);
|
||||
await ctx.commit()
|
||||
} catch (e) {
|
||||
console.error('执行internalErrorHandler时出错', e);
|
||||
await ctx.rollback();
|
||||
} finally {
|
||||
resolve();
|
||||
}
|
||||
|
|
@ -625,6 +627,7 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Backe
|
|||
try {
|
||||
const result = await routineFn(context, {
|
||||
socket: this.nsSocket!,
|
||||
contextBuilder: () => this.makeContext(),
|
||||
});
|
||||
console.log(`例程【${name}】执行成功,耗时${Date.now() - start}毫秒,结果是【${result}】`);
|
||||
await context.commit();
|
||||
|
|
@ -661,6 +664,7 @@ export class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends Backe
|
|||
try {
|
||||
const result = await routineFn(context, {
|
||||
socket: this.nsSocket!,
|
||||
contextBuilder: () => this.makeContext(),
|
||||
});
|
||||
console.log(`例程【${name}】执行成功,耗时${Date.now() - start}毫秒,结果是【${result}】`);
|
||||
await context.commit();
|
||||
|
|
|
|||
Loading…
Reference in New Issue