mirror of
https://github.com/HeyPuter/puter.git
synced 2026-02-11 00:08:54 -06:00
fix: add context to event listener aiife
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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,
|
||||
});
|
||||
}
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user