fix: don't wrap functions twice in entrypoint

This commit is contained in:
PalmDevs 2025-07-03 20:55:26 +07:00
parent 24c4985ae8
commit 2f21be2c52
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -18,7 +18,7 @@ import { getErrorStack } from '@revenge-mod/utils/errors'
const IndexModuleId = 0
onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
runCatching(() => {
try {
if (__BUILD_FLAG_LOG_PROMISE_REJECTIONS__)
require('./patches/log-promise-rejections')
@ -34,7 +34,7 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
require('@revenge-mod/plugins/preinit')
onModuleInitialized(IndexModuleId, function onIndexInitialized() {
runCatching(() => {
try {
// Initialize init libraries
require('@revenge-mod/storage/init')
require('@revenge-mod/externals/init')
@ -44,28 +44,28 @@ onModuleFirstRequired(IndexModuleId, function onIndexRequired() {
// Run all init plugins
require('~/plugins/init')
require('@revenge-mod/plugins/init')
})
} catch (e) {
onError(e)
}
})
})
} catch (e) {
onError(e)
}
})
function runCatching(fn: () => void) {
try {
fn()
} catch (e) {
// TODO(init): Move to use native provided alert function, which will accept a string stack trace
// Above will reduce the need for runCatching() to exist, as the code won't be able to be deduped any further
const { ClientInfoModule, DeviceModule } =
require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native')
function onError(e: unknown) {
// TODO(init): Move to use native provided alert function, which will accept a string stack trace
// Above will reduce the need for runCatching() to exist, as the code won't be able to be deduped any further
const { ClientInfoModule, DeviceModule } =
require('@revenge-mod/discord/native') as typeof import('@revenge-mod/discord/native')
const Client = ClientInfoModule.getConstants()
const Device = DeviceModule.getConstants()
const Client = ClientInfoModule.getConstants()
const Device = DeviceModule.getConstants()
alert(
`Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` +
`Discord: ${Client.Version} (${Client.Build})\n` +
`Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` +
getErrorStack(e),
)
}
alert(
`Failed to load Revenge (${__BUILD_VERSION__}-${__BUILD_COMMIT__}-${__BUILD_BRANCH__} (${__BUILD_ENV__}))\n` +
`Discord: ${Client.Version} (${Client.Build})\n` +
`Device: ${Device.deviceManufacturer} ${Device.deviceModel}\n\n` +
getErrorStack(e),
)
}