ruvnet/ruflo · error
File too large: bytes exceeds
Error message
File too large: ${code.length} bytes exceeds ${this.config.maxFileSize} What it means
ASTAnalyzer.analyze() refuses to parse source above config.maxFileSize bytes to protect the parser from pathological inputs. The default cap is 1,048,576 (1 MiB), set at ast-analyzer.ts:46; the check uses code.length (UTF-16 code units), so files heavy in non-ASCII characters hit the cap even when their byte size on disk is similar.
Solutions
- Exclude or chunk the offending file — analyze per-module sources instead of bundles
- Pass a higher maxFileSize in the analyzer config: { maxFileSize: 4 * 1024 * 1024 } (constructor/createASTAnalyzer accepts it)
- Skip known-generated paths (dist, build, *.min.js) before analysis
- Pre-check size and log a warning rather than letting analyze() throw mid-batch
Example fix
// before
const result = analyzer.analyze(code, filePath); // throws on >1MiB files
// after
const MAX = 1024 * 1024;
if (code.length > MAX) {
console.warn(`skipping ${filePath}: ${code.length} > ${MAX} chars`);
} else {
const result = analyzer.analyze(code, filePath);
}
// or raise the cap:
// const analyzer = new ASTAnalyzer({ maxFileSize: 4 * 1024 * 1024 }); Defensive patterns
Strategy: validation
Validate before calling
const MAX_CHARS = 1024 * 1024; // default maxFileSize, ast-analyzer.ts:46
function analyzeSafe(analyzer: { analyze(c: string, f?: string): unknown }, code: string, filePath: string) {
if (code.length > MAX_CHARS) return null; // caller skips or chunks
return analyzer.analyze(code, filePath);
} Type guard
const isWithinSizeLimit = (code: string, max = 1024 * 1024): boolean => code.length <= max;
Try / catch
try {
result = analyzer.analyze(code, filePath);
} catch (e) {
if (e instanceof Error && e.message.startsWith('File too large')) {
result = null; // skip oversized file, keep the batch alive
} else throw e;
} Prevention
- Exclude dist/, build/, *.min.js and vendor bundles from AST analysis passes
- If you raise maxFileSize, profile first — the cap protects parser time and memory
- Check code.length (UTF-16 units), not Buffer.byteLength, to mirror the library's check
When it happens
Trigger: Calling analyze() on minified bundles, lockfile-scale sources, or generated files over 1 MiB; raising nothing and feeding dist/*.js; analyzing a file where code.length counts surrogate pairs, crossing the limit near ~1M characters.
Common situations: Running AST analysis over an entire repo including dist/ and node_modules artifacts; vendored SDK bundles; snapshot or fixture files; defaults left untouched because the config object was constructed partially.
Understand the failure class
Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.
Related errors
- AUTHENTICATION
- AUTHENTICATION
- AUTHENTICATION
- browser/eval: script contains disallowed pattern
- Config file already exists
AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18).
Data as JSON: /api/errors/aa36329b3fd38a32.
Report an issue: GitHub.
Appendix: source
Thrown at v3/@claude-flow/cli/src/ruvector/ast-analyzer.ts:87
}
async initialize(): Promise<void> {
try {
// @ruvector/ast is optional - gracefully fallback if not installed
const ruvector = await import('@ruvector/ast' as string).catch(() => null);
if (ruvector) {
this.ruvectorEngine = (ruvector as any).createASTAnalyzer?.(this.config);
this.useNative = !!this.ruvectorEngine;
}
} catch {
this.useNative = false;
}
}
analyze(code: string, filePath: string = 'unknown'): ASTAnalysis {
const startTime = performance.now();
if (code.length > this.config.maxFileSize) {
throw new Error(`File too large: ${code.length} bytes exceeds ${this.config.maxFileSize}`);
}
const cacheKey = this.getCacheKey(code, filePath);
const cached = this.analysisCache.get(cacheKey);
if (cached) return cached;
const language = this.detectLanguage(code, filePath);
const root = this.parseAST(code, language);
const functions = this.extractFunctions(root);
const classes = this.extractClasses(root);
const imports = this.extractImports(code, language);
const exports = this.extractExports(code, language);
const complexity = this.calculateComplexity(code, root);
const durationMs = performance.now() - startTime;
const analysis: ASTAnalysis = {
filePath, language, root, functions, classes, imports, exports,
complexity, timestamp: Date.now(), durationMs,
};
this.analysisCache.set(cacheKey, analysis);
return analysis;View on GitHub (pinned to fa13ee4ad6)