From 43b6933fe69fbf30f542c7da41d0e812150f8447 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Thu, 6 Jun 2024 00:47:57 -0300 Subject: [PATCH] Reporter: Include page errors; load wasm chunks --- scripts/generateReport.ts | 9 ++++++++- src/debug/loadLazyChunks.ts | 14 ++++++++------ src/plugins/appleMusic.desktop/index.tsx | 3 ++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/scripts/generateReport.ts b/scripts/generateReport.ts index cf421077..2a802da8 100644 --- a/scripts/generateReport.ts +++ b/scripts/generateReport.ts @@ -286,7 +286,14 @@ page.on("console", async e => { }); page.on("error", e => console.error("[Error]", e.message)); -page.on("pageerror", e => console.error("[Page Error]", e.message)); +page.on("pageerror", e => { + if (!e.message.startsWith("Object") && !e.message.includes("Cannot find module")) { + console.error("[Page Error]", e.message); + report.otherErrors.push(e.message); + } else { + report.ignoredErrors.push(e.message); + } +}); async function reporterRuntime(token: string) { Vencord.Webpack.waitFor( diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index d8f84335..0aeae732 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -47,11 +47,11 @@ export async function loadLazyChunks() { for (const id of chunkIds) { if (wreq.u(id) == null || wreq.u(id) === "undefined.js") continue; - const isWasm = await fetch(wreq.p + wreq.u(id)) + const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); + .then(t => t.includes("importScripts(")); - if (isWasm && IS_WEB) { + if (isWorkerAsset) { invalidChunks.add(id); invalidChunkGroup = true; continue; @@ -149,13 +149,15 @@ export async function loadLazyChunks() { }); await Promise.all(chunksLeft.map(async id => { - const isWasm = await fetch(wreq.p + wreq.u(id)) + const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) - .then(t => (IS_WEB && t.includes(".module.wasm")) || !t.includes("(this.webpackChunkdiscord_app=this.webpackChunkdiscord_app||[]).push")); + .then(t => t.includes("importScripts(")); // Loads and requires a chunk - if (!isWasm) { + if (!isWorkerAsset) { await wreq.e(id as any); + // Technically, the id of the chunk does not match the entry point + // But, still try it because we have no way to get the actual entry point if (wreq.m[id]) wreq(id as any); } })); diff --git a/src/plugins/appleMusic.desktop/index.tsx b/src/plugins/appleMusic.desktop/index.tsx index 16591028..ef3ee3ef 100644 --- a/src/plugins/appleMusic.desktop/index.tsx +++ b/src/plugins/appleMusic.desktop/index.tsx @@ -6,7 +6,7 @@ import { definePluginSettings } from "@api/Settings"; import { Devs } from "@utils/constants"; -import definePlugin, { OptionType, PluginNative } from "@utils/types"; +import definePlugin, { OptionType, PluginNative, ReporterTestable } from "@utils/types"; import { ApplicationAssetUtils, FluxDispatcher, Forms } from "@webpack/common"; const Native = VencordNative.pluginHelpers.AppleMusic as PluginNative; @@ -171,6 +171,7 @@ export default definePlugin({ description: "Discord rich presence for your Apple Music!", authors: [Devs.RyanCaoDev], hidden: !navigator.platform.startsWith("Mac"), + reporterTestable: ReporterTestable.None, settingsAboutComponent() { return <>