Skip to content

Commit 37a2016

Browse files
committed
fix: do not use emitter to emit error event
Discord's EventEmitter handles the `error` event specially for some reason.
1 parent 7bfb703 commit 37a2016

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/discord/src/common/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const [, _createClassModuleId] = lookupModule(byName('_createClass'))
1111
const [, _classCallCheckModuleId] = lookupModule(byName('_classCallCheck'))
1212

1313
// ../discord_common/js/shared/utils/TypedEventEmitter.tsx
14+
/**
15+
* Do not use the `error` event, as the module will handle it specially for some reason.
16+
*/
1417
export let TypedEventEmitter: typeof DiscordModules.Utils.TypedEventEmitter =
1518
proxify(() => {
1619
const [module] = lookupModule(

lib/plugins/src/_internal.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const pEmitter = new TypedEventEmitter<{
3030
start: [InternalPlugin, PluginApi]
3131
started: [InternalPlugin]
3232
stopped: [InternalPlugin]
33-
error: [InternalPlugin, unknown]
33+
errored: [InternalPlugin, unknown]
3434
}>()
3535

3636
export const pList = new Map<PluginManifest['id'], InternalPlugin>()
@@ -88,7 +88,7 @@ function handlePluginError(e: unknown, plugin: InternalPlugin) {
8888
2,
8989
)
9090

91-
pEmitter.emit('error', plugin, e)
91+
pEmitter.emit('errored', plugin, e)
9292

9393
if (!(iflags & InternalPluginFlags.Essential)) return plugin.disable()
9494
}

src/plugins/init/developer-settings/react-devtools.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const RDTContext: {
2121
const events = new TypedEventEmitter<{
2222
connect: []
2323
disconnect: []
24-
error: [unknown]
24+
errored: [unknown]
2525
}>()
2626

2727
const CircleXIcon = lookupGeneratedIconComponent(
@@ -47,7 +47,7 @@ export function connect() {
4747

4848
ws.addEventListener('error', e => {
4949
cleanup()
50-
events.emit('error', e)
50+
events.emit('errored', e)
5151

5252
const err = (e as { message: string }).message ?? getErrorStack(e)
5353
api.logger.error('React DevTools error:', err)

0 commit comments

Comments
 (0)