mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-10 01:39:02 +00:00
Some checks are pending
Publish Fork Image to GHCR / Build and Push Fork Image (push) Waiting to run
CI / Change Classification (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Quality Ratchet (push) Blocked by required conditions
CI / Quality Gates (Extended) (push) Waiting to run
CI / Docs Sync (Strict) (push) Waiting to run
CI / Docs Lint (prose — advisory) (push) Waiting to run
CI / i18n UI Coverage (push) Waiting to run
CI / i18n Validation (all languages) (push) Waiting to run
CI / PR Test Policy (push) Waiting to run
CI / Build (push) Blocked by required conditions
CI / Package Artifact (push) Blocked by required conditions
CI / Electron Package Smoke (push) Blocked by required conditions
CI / Unit Tests (1/8) (push) Blocked by required conditions
CI / Unit Tests (2/8) (push) Blocked by required conditions
CI / Unit Tests (3/8) (push) Blocked by required conditions
CI / Unit Tests (4/8) (push) Blocked by required conditions
CI / Unit Tests (5/8) (push) Blocked by required conditions
CI / Unit Tests (6/8) (push) Blocked by required conditions
CI / Unit Tests (7/8) (push) Blocked by required conditions
CI / Unit Tests (8/8) (push) Blocked by required conditions
CI / Vitest (MCP / autoCombo / UI components) (push) Blocked by required conditions
CI / Coverage (push) Blocked by required conditions
CI / SonarQube (push) Blocked by required conditions
CI / PR Coverage Comment (push) Blocked by required conditions
CI / E2E Tests (1/9) (push) Blocked by required conditions
CI / E2E Tests (2/9) (push) Blocked by required conditions
CI / E2E Tests (3/9) (push) Blocked by required conditions
CI / E2E Tests (4/9) (push) Blocked by required conditions
CI / E2E Tests (5/9) (push) Blocked by required conditions
CI / E2E Tests (6/9) (push) Blocked by required conditions
CI / E2E Tests (7/9) (push) Blocked by required conditions
CI / E2E Tests (8/9) (push) Blocked by required conditions
CI / E2E Tests (9/9) (push) Blocked by required conditions
CI / Integration Tests (1/2) (push) Blocked by required conditions
CI / Integration Tests (2/2) (push) Blocked by required conditions
CI / Security Tests (push) Blocked by required conditions
CI / CI Dashboard (push) Blocked by required conditions
Publish to Docker Hub / Resolve Docker release metadata (push) Waiting to run
Publish to Docker Hub / Build Docker (linux/amd64) (push) Blocked by required conditions
Publish to Docker Hub / Build Docker (linux/arm64) (push) Blocked by required conditions
Publish to Docker Hub / Publish multi-arch manifests (push) Blocked by required conditions
OpenSSF Scorecard / Scorecard analysis (push) Waiting to run
semgrep / semgrep (push) Waiting to run
Wiki Sync / Sync wiki with docs (push) Waiting to run
Release v3.8.46. Full changelog: CHANGELOG.md → [3.8.46]. Contributor attribution in the CHANGELOG entries.
74 lines
2.7 KiB
JavaScript
74 lines
2.7 KiB
JavaScript
// Best-effort self-heal for a corrupted Turbopack persistent dev cache.
|
|
//
|
|
// Context (#6289): on Windows, `pnpm dev` can fail at startup when Turbopack
|
|
// mmaps a persistent-cache SST file and the OS refuses the mapping
|
|
// ("os error 1455" — "paging file too small"). Turbopack then surfaces a
|
|
// misleading `Module not found: Can't resolve '@/shared/utils/machine'`.
|
|
// This is a known UPSTREAM Turbopack cache-corruption bug — NOT our code.
|
|
// The reliable remedy is deleting the Turbopack cache dir; this module lets
|
|
// the dev launcher attempt that automatically once before giving up.
|
|
//
|
|
// Pure + side-effect-isolated so it can be unit-tested without booting Next.
|
|
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
// Signature of the corrupted-cache failure. Kept intentionally broad because
|
|
// the same corruption surfaces through several messages (the raw mmap/SST
|
|
// error, the Windows paging-file error code, and the misleading module-resolve
|
|
// error emitted by Turbopack's "restore task data" step).
|
|
const CORRUPTION_SIGNATURE = /restore task data|mmap .*SST|os error 1455|paging file/i;
|
|
|
|
/**
|
|
* True when an error message looks like a corrupted Turbopack persistent cache.
|
|
* @param {unknown} message
|
|
* @returns {boolean}
|
|
*/
|
|
export function isTurbopackCacheCorruption(message) {
|
|
if (message == null) return false;
|
|
return CORRUPTION_SIGNATURE.test(String(message));
|
|
}
|
|
|
|
/**
|
|
* Candidate Turbopack cache directories for a given Next dist dir. Next has
|
|
* placed the persistent cache under both `<distDir>/cache/turbopack` and
|
|
* `<distDir>/dev/cache/turbopack` across versions, so purge both.
|
|
* @param {string} [distDir]
|
|
* @param {string} [cwd]
|
|
* @returns {string[]}
|
|
*/
|
|
export function turbopackCacheDirs(
|
|
distDir = process.env.NEXT_DIST_DIR || ".build/next",
|
|
cwd = process.cwd()
|
|
) {
|
|
const base = path.isAbsolute(distDir) ? distDir : path.join(cwd, distDir);
|
|
return [
|
|
path.join(base, "cache", "turbopack"),
|
|
path.join(base, "dev", "cache", "turbopack"),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Recursively remove a single Turbopack cache directory.
|
|
* @param {string} dir
|
|
* @returns {boolean} true if the directory existed and was removed
|
|
*/
|
|
export function purgeTurbopackCache(dir) {
|
|
if (!dir || !fs.existsSync(dir)) return false;
|
|
fs.rmSync(dir, { recursive: true, force: true });
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Purge every candidate Turbopack cache directory for the given dist dir.
|
|
* @param {string} [distDir]
|
|
* @param {string} [cwd]
|
|
* @returns {string[]} the directories that existed and were removed
|
|
*/
|
|
export function purgeAllTurbopackCaches(distDir, cwd) {
|
|
const removed = [];
|
|
for (const dir of turbopackCacheDirs(distDir, cwd)) {
|
|
if (purgeTurbopackCache(dir)) removed.push(dir);
|
|
}
|
|
return removed;
|
|
}
|