{"record":{"id":"f3f2ce2eeb4afb1c","repo":"n8n-io/n8n","slug":"snapshot-not-found-filename-tried-filepath","errorCode":null,"errorMessage":"Snapshot not found: ${filename} (tried ${filePath})","messagePattern":"Snapshot not found: (.+?) \\(tried (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"packages/cli/src/controllers/e2e.controller.ts","lineNumber":423,"sourceCode":"\n\t/**\n\t * Download a heap snapshot file as a stream.\n\t * The response-helper pipes Readable streams directly to the response.\n\t */\n\t@Get('/heap-snapshot/:filename', { skipAuth: true })\n\tdownloadHeapSnapshot(req: Request) {\n\t\tconst fs = require('node:fs') as typeof nodeFs;\n\t\tconst path = require('node:path') as typeof nodePath;\n\n\t\tconst filename = path.basename(req.params.filename);\n\t\tif (!filename.endsWith('.heapsnapshot')) {\n\t\t\tthrow new Error('Invalid file type');\n\t\t}\n\n\t\t// Look up the full path stored during POST, or try cwd\n\t\tconst filePath = this.heapSnapshotPaths.get(filename) ?? path.resolve(filename);\n\t\tif (!fs.existsSync(filePath)) {\n\t\t\tthrow new Error(`Snapshot not found: ${filename} (tried ${filePath})`);\n\t\t}\n\n\t\treturn fs.createReadStream(filePath);\n\t}\n\n\t// --- Per-spec backend V8 coverage (DEVP-370) -----------------------------\n\t// Lets the Playwright coverage fixture attribute this main process's V8\n\t// coverage to the spec that produced it, so backend source files land in the\n\t// E2E impact map (today the map is frontend-only). Test-only: the whole\n\t// controller hard-exits outside E2E (see top of file).\n\t//\n\t// Uses `Profiler.getBestEffortCoverage` (NON-draining) + a server-side\n\t// baseline/delta so it never resets the global V8 counters — the shard-level\n\t// `NODE_V8_COVERAGE` exit dump (the Codecov report path) is left untouched.\n\t//\n\t// REQUIRES the coverage run to be single-worker (it is — coverage project\n\t// runs `--workers=1`). Precise coverage is process-global, so the start→take\n\t// window is only attributable to one spec when specs don't run concurrently.","sourceCodeStart":405,"sourceCodeEnd":441,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/cli/src/controllers/e2e.controller.ts#L405-L441","documentation":"Plain `Error('Snapshot not found: <filename> (tried <filePath>)')` thrown at e2e.controller.ts:423 when the resolved heap-snapshot file path (from `heapSnapshotPaths` map or `path.resolve(filename)` in cwd) does not exist via `fs.existsSync`. Test-only controller; serialized as a 500 by the generic handler. The message leaks the absolute path tried.","triggerScenarios":"In E2E mode: requesting a `.heapsnapshot` filename that was never recorded by the POST route, was already cleaned up, or whose file lives outside the resolved base path. The map lookup falls back to cwd, so a relative-name mismatch also triggers it.","commonSituations":"Playwright run ordering (download before POST completed); temp-file cleanup between runs; running the GET from a different cwd than the POST; fixture using a fabricated filename.","solutions":["Ensure the POST `/e2e/heap-snapshot` route ran and registered the filename in `heapSnapshotPaths` before GET.","Use the exact filename returned by POST — do not synthesize one.","Disable any cleanup that removes `.heapsnapshot` files mid-test-run.","Run the test from the same working directory as the controller process."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { existsSync } from 'node:fs';\nfunction snapshotReady(p: string) { return existsSync(p); }\n// in the test: assert snapshotReady(filePath) before GET","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Order Playwright specs: POST heap-snapshot must complete before GET.","Run GET from the same cwd as the controller, or use the exact stored filename.","Disable mid-run cleanup that removes .heapsnapshot files."],"tags":["e2e","test-only","heap-snapshot","not-found"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}