mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
fix: add context to event listener aiife
This commit is contained in:
parent
2898ff681f
commit
3f07ead1b9
@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU Affero General Public License
|
* 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/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
const { Context } = require("../util/context");
|
||||||
const BaseService = require("./BaseService");
|
const BaseService = require("./BaseService");
|
||||||
|
|
||||||
class ScopedEventBus {
|
class ScopedEventBus {
|
||||||
@ -55,7 +56,7 @@ class EventService extends BaseService {
|
|||||||
|
|
||||||
// IIAFE wrapper to catch errors without blocking
|
// IIAFE wrapper to catch errors without blocking
|
||||||
// event dispatch.
|
// event dispatch.
|
||||||
(async () => {
|
Context.arun(async () => {
|
||||||
try {
|
try {
|
||||||
await callback(key, data, meta);
|
await callback(key, data, meta);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -65,14 +66,14 @@ class EventService extends BaseService {
|
|||||||
alarm: true,
|
alarm: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( const callback of this.global_listeners_ ) {
|
for ( const callback of this.global_listeners_ ) {
|
||||||
// IIAFE wrapper to catch errors without blocking
|
// IIAFE wrapper to catch errors without blocking
|
||||||
// event dispatch.
|
// event dispatch.
|
||||||
(async () => {
|
Context.arun(async () => {
|
||||||
try {
|
try {
|
||||||
await callback(key, data, meta);
|
await callback(key, data, meta);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -82,7 +83,7 @@ class EventService extends BaseService {
|
|||||||
alarm: true,
|
alarm: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,9 @@ class Context {
|
|||||||
static describe () {
|
static describe () {
|
||||||
return this.get().describe();
|
return this.get().describe();
|
||||||
}
|
}
|
||||||
|
static arun (cb) {
|
||||||
|
return this.get().arun(cb);
|
||||||
|
}
|
||||||
get (k) {
|
get (k) {
|
||||||
return this.values_[k];
|
return this.values_[k];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user