fix: do not use emitter to emit error event
Discord's EventEmitter handles the `error` event specially for some reason.
This commit is contained in:
parent
7bfb703e01
commit
37a20160db
3 changed files with 7 additions and 4 deletions
|
|
@ -11,6 +11,9 @@ const [, _createClassModuleId] = lookupModule(byName('_createClass'))
|
|||
const [, _classCallCheckModuleId] = lookupModule(byName('_classCallCheck'))
|
||||
|
||||
// ../discord_common/js/shared/utils/TypedEventEmitter.tsx
|
||||
/**
|
||||
* Do not use the `error` event, as the module will handle it specially for some reason.
|
||||
*/
|
||||
export let TypedEventEmitter: typeof DiscordModules.Utils.TypedEventEmitter =
|
||||
proxify(() => {
|
||||
const [module] = lookupModule(
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export const pEmitter = new TypedEventEmitter<{
|
|||
start: [InternalPlugin, PluginApi]
|
||||
started: [InternalPlugin]
|
||||
stopped: [InternalPlugin]
|
||||
error: [InternalPlugin, unknown]
|
||||
errored: [InternalPlugin, unknown]
|
||||
}>()
|
||||
|
||||
export const pList = new Map<PluginManifest['id'], InternalPlugin>()
|
||||
|
|
@ -88,7 +88,7 @@ function handlePluginError(e: unknown, plugin: InternalPlugin) {
|
|||
2,
|
||||
)
|
||||
|
||||
pEmitter.emit('error', plugin, e)
|
||||
pEmitter.emit('errored', plugin, e)
|
||||
|
||||
if (!(iflags & InternalPluginFlags.Essential)) return plugin.disable()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ export const RDTContext: {
|
|||
const events = new TypedEventEmitter<{
|
||||
connect: []
|
||||
disconnect: []
|
||||
error: [unknown]
|
||||
errored: [unknown]
|
||||
}>()
|
||||
|
||||
const CircleXIcon = lookupGeneratedIconComponent(
|
||||
|
|
@ -47,7 +47,7 @@ export function connect() {
|
|||
|
||||
ws.addEventListener('error', e => {
|
||||
cleanup()
|
||||
events.emit('error', e)
|
||||
events.emit('errored', e)
|
||||
|
||||
const err = (e as { message: string }).message ?? getErrorStack(e)
|
||||
api.logger.error('React DevTools error:', err)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue