diff --git a/src/backend/src/services/EventService.js b/src/backend/src/services/EventService.js index d668b992..89417ed5 100644 --- a/src/backend/src/services/EventService.js +++ b/src/backend/src/services/EventService.js @@ -16,6 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ +const { Context } = require("../util/context"); const BaseService = require("./BaseService"); class ScopedEventBus { @@ -55,7 +56,7 @@ class EventService extends BaseService { // IIAFE wrapper to catch errors without blocking // event dispatch. - (async () => { + Context.arun(async () => { try { await callback(key, data, meta); } catch (e) { @@ -65,14 +66,14 @@ class EventService extends BaseService { alarm: true, }); } - })(); + }); } } for ( const callback of this.global_listeners_ ) { // IIAFE wrapper to catch errors without blocking // event dispatch. - (async () => { + Context.arun(async () => { try { await callback(key, data, meta); } catch (e) { @@ -82,7 +83,7 @@ class EventService extends BaseService { alarm: true, }); } - })(); + }); } } diff --git a/src/backend/src/util/context.js b/src/backend/src/util/context.js index 4e222caf..91948b8f 100644 --- a/src/backend/src/util/context.js +++ b/src/backend/src/util/context.js @@ -60,6 +60,9 @@ class Context { static describe () { return this.get().describe(); } + static arun (cb) { + return this.get().arun(cb); + } get (k) { return this.values_[k]; }