babalae/better-genshin-impact · error · FileNotFoundException
main js is empty.
Error message
main js is empty.
What it means
Thrown by ScriptProject.LoadCode when the main JS file (specified by Manifest.Main) exists but contains empty or null content. Despite the exception type being FileNotFoundException, the file exists — it's just empty. This is a content validation check after reading the file.
Source
Thrown at BetterGenshinImpact/Core/Script/Project/ScriptProject.cs:167
try
{
engine.Interrupt();
}
catch (Exception e)
{
TaskControl.Logger.LogError(e, "中断脚本执行异常:" + e.Message);
}
engine.Dispose();
}
}
public async Task<string> LoadCode()
{
var code = await File.ReadAllTextAsync(Path.Combine(ProjectPath, Manifest.Main));
if (string.IsNullOrEmpty(code))
{
throw new FileNotFoundException("main js is empty.");
}
return code;
}
}View on GitHub (pinned to a7cb36712d)
Solutions
- Open the main JS file and verify it contains executable JavaScript code.
- If the file is empty, add the script logic or restore from a backup/version control.
- Check file size: if 0 bytes, re-download or recreate the script.
- Use a script template to ensure the main file has valid content.
Defensive patterns
Strategy: validation
Validate before calling
var code = await File.ReadAllTextAsync(Path.Combine(projectPath, manifest.Main));
if (string.IsNullOrWhiteSpace(code))
throw new InvalidOperationException($"Main JS file is empty: {manifest.Main}"); Try / catch
try
{
var code = await project.LoadCode();
}
catch (FileNotFoundException ex) when (ex.Message.Contains("main js is empty"))
{
TaskControl.Logger.LogError("Main JS file has no content");
} Prevention
- Check file size after extracting/downloading script packages — zero-byte files indicate corruption.
- Ensure the main JS file contains valid JavaScript before deployment.
- Use version control to track script file integrity.
When it happens
Trigger: Calling LoadCode() on a ScriptProject where Path.Combine(ProjectPath, Manifest.Main) exists but File.ReadAllTextAsync returns an empty string. The main JS entry-point file has zero bytes or only whitespace that gets read as empty.
Common situations: The main.js file was created but never filled with code. A file sync or extraction issue resulted in a zero-byte file. The script author created a placeholder file. A Git operation (merge, rebase) left the file empty.
Related errors
- manifest.json: name is required.
- manifest.json: version is required.
- manifest.json: main script is required.
- main js file not found.
- milliseconds 不能小于 0
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/476c6cb66bc3b3db.
Report an issue: GitHub.