Skip to content

Commit

Permalink
fix: bug where unknown events crash astral
Browse files Browse the repository at this point in the history
  • Loading branch information
lino-levan committed Sep 4, 2024
1 parent 82852c5 commit 43e995d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bindings/_tools/generate/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ export class Celestial extends EventTarget {
this.#handlers.delete(data.id);
} else {
const className = CelestialEvents[data.method as keyof CelestialEventMap];
if (className === undefined) {
if (DEBUG) {
console.error("[CELESTIAL] Unknown event", data);
}
return;
}
if(data.params) {
this.dispatchEvent(new className(data.params))
} else {
Expand Down
6 changes: 6 additions & 0 deletions bindings/celestial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13760,6 +13760,12 @@ export class Celestial extends EventTarget {
} else {
const className =
CelestialEvents[data.method as keyof CelestialEventMap];
if (className === undefined) {
if (DEBUG) {
console.error("[CELESTIAL] Unknown event", data);
}
return;
}
if (data.params) {
this.dispatchEvent(new className(data.params));
} else {
Expand Down

0 comments on commit 43e995d

Please sign in to comment.