From dd93f274991bb8a1f4482d9f3b7dca8b5e33eb16 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Thu, 19 Mar 2026 09:32:30 +0100 Subject: [PATCH] ci: fix resource exhaustion errors --- .github/workflows/reportBrokenPlugins.yml | 8 +------- package.json | 1 + pnpm-lock.yaml | 20 ++++++++++++++++++- src/debug/loadLazyChunks.ts | 24 ++++++++++++++--------- 4 files changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/reportBrokenPlugins.yml b/.github/workflows/reportBrokenPlugins.yml index f1e53e4d..8c90a4e5 100644 --- a/.github/workflows/reportBrokenPlugins.yml +++ b/.github/workflows/reportBrokenPlugins.yml @@ -44,12 +44,6 @@ jobs: run: | pnpm install --frozen-lockfile - - name: Install Google Chrome - id: setup-chrome - uses: browser-actions/setup-chrome@82b9ce628cc5595478a9ebadc480958a36457dc2 - with: - chrome-version: stable - - name: Build Vencord Reporter Version run: pnpm buildReporter @@ -57,7 +51,7 @@ jobs: timeout-minutes: 10 run: | export PATH="$PWD/node_modules/.bin:$PATH" - export CHROMIUM_BIN=${{ steps.setup-chrome.outputs.chrome-path }} + export CHROMIUM_BIN=/usr/bin/google-chrome esbuild scripts/generateReport.ts > dist/report.mjs diff --git a/package.json b/package.json index 0061e54a..6722df78 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,7 @@ "highlight.js": "11.11.1", "html-minifier-terser": "^7.2.0", "moment": "^2.22.2", + "p-limit": "^7.3.0", "puppeteer-core": "^24.30.0", "standalone-electron-types": "^34.2.0", "stylelint": "^16.25.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0a090595..baca9c22 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -98,6 +98,9 @@ importers: moment: specifier: ^2.22.2 version: 2.30.1 + p-limit: + specifier: ^7.3.0 + version: 7.3.0 puppeteer-core: specifier: ^24.30.0 version: 24.30.0 @@ -966,6 +969,7 @@ packages: basic-ftp@5.0.5: resolution: {integrity: sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==} engines: {node: '>=10.0.0'} + deprecated: Security vulnerability fixed in 5.2.0, please upgrade boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} @@ -2154,6 +2158,10 @@ packages: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} + p-limit@7.3.0: + resolution: {integrity: sha512-7cIXg/Z0M5WZRblrsOla88S4wAK+zOQQWeBYfV3qJuJXMr+LnbYjaadrFaS0JILfEDPVqHyKnZ1Z/1d6J9VVUw==} + engines: {node: '>=20'} + p-locate@5.0.0: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} @@ -2814,6 +2822,10 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} + yocto-queue@1.2.2: + resolution: {integrity: sha512-4LCcse/U2MHZ63HAJVE+v71o7yOdIe4cZ70Wpf8D/IyjDKYQLV5GD46B+hSTjJsvV5PztjvHoU580EftxjDZFQ==} + engines: {node: '>=12.20'} + zip-local@0.3.5: resolution: {integrity: sha512-GRV3D5TJY+/PqyeRm5CYBs7xVrKTKzljBoEXvocZu0HJ7tPEcgpSOYa2zFIsCZWgKWMuc4U3yMFgFkERGFIB9w==} @@ -3193,7 +3205,7 @@ snapshots: '@types/react-dom@18.3.1': dependencies: - '@types/react': 18.3.1 + '@types/react': 19.0.12 '@types/react-dom@19.0.4(@types/react@19.0.12)': dependencies: @@ -4899,6 +4911,10 @@ snapshots: dependencies: yocto-queue: 0.1.0 + p-limit@7.3.0: + dependencies: + yocto-queue: 1.2.2 + p-locate@5.0.0: dependencies: p-limit: 3.1.0 @@ -5726,6 +5742,8 @@ snapshots: yocto-queue@0.1.0: {} + yocto-queue@1.2.2: {} + zip-local@0.3.5: dependencies: async: 1.5.2 diff --git a/src/debug/loadLazyChunks.ts b/src/debug/loadLazyChunks.ts index 94a9f6a3..424724bb 100644 --- a/src/debug/loadLazyChunks.ts +++ b/src/debug/loadLazyChunks.ts @@ -9,6 +9,7 @@ import { canonicalizeMatch } from "@utils/patches"; import { ModuleFactory } from "@vencord/discord-types/webpack"; import * as Webpack from "@webpack"; import { wreq } from "@webpack"; +import pLimit from "p-limit"; import { AnyModuleFactory } from "webpack"; function getWebpackChunkMap() { @@ -31,6 +32,7 @@ function getWebpackChunkMap() { export async function loadLazyChunks() { const LazyChunkLoaderLogger = new Logger("LazyChunkLoader"); + const queue = pLimit(50); try { LazyChunkLoaderLogger.log("Loading all chunks..."); @@ -59,11 +61,15 @@ export async function loadLazyChunks() { const shouldForceDefer = false; - await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => { - const chunkIds = rawChunkIds ? Array.from(rawChunkIds.matchAll(Webpack.ChunkIdsRegex)).map(m => { - const numChunkId = Number(m[1]); - return Number.isNaN(numChunkId) ? m[1] : numChunkId; - }) : []; + await Promise.all(Array.from(lazyChunks).map(async ([, rawChunkIds, entryPoint]) => queue(async () => { + const chunkIds = rawChunkIds + ?.matchAll(Webpack.ChunkIdsRegex) + .map(m => { + const numChunkId = Number(m[1]); + return Number.isNaN(numChunkId) ? m[1] : numChunkId; + }) + .toArray() + ?? []; if (chunkIds.length === 0) { return; @@ -101,13 +107,13 @@ export async function loadLazyChunks() { const numEntryPoint = Number(entryPoint); validChunkGroups.add([chunkIds, Number.isNaN(numEntryPoint) ? entryPoint : numEntryPoint]); } - })); + }))); // Loads all found valid chunk groups await Promise.all( Array.from(validChunkGroups) .map(([chunkIds]) => - Promise.all(chunkIds.map(id => wreq.e(id))) + Promise.all(chunkIds.map(id => queue(() => wreq.e(id)))) ) ); @@ -182,7 +188,7 @@ export async function loadLazyChunks() { return !(validChunks.has(id) || invalidChunks.has(id)); }); - await Promise.all(chunksLeft.map(async id => { + await Promise.all(chunksLeft.map(async id => queue(async () => { const isWorkerAsset = await fetch(wreq.p + wreq.u(id)) .then(r => r.text()) .then(t => /importScripts\(|self\.postMessage/.test(t)); @@ -191,7 +197,7 @@ export async function loadLazyChunks() { if (!isWorkerAsset) { await wreq.e(id); } - })); + }))); LazyChunkLoaderLogger.log("Finished loading all chunks!"); } catch (e) {