agalwood/Motrix · error · AppError
MagnetResolveFailed
MagnetResolveFailed
Error message
saved torrent metadata is no longer available for task ${taskId} What it means
Thrown by `reopenFileSelection` (magnet-tracker.ts:783) when neither the in-cache torrent base64 nor the on-disk `pair.task.torrentMetaPath` file could supply the metadata bytes (the read threw, captured as `sourceError`). The saved `.torrent` that backed the MetadataReady magnet is gone, so the file-selection window cannot be re-opened.
Source
Thrown at src/core/torrent/magnet-tracker.ts:783
if (metadataDir) {
try {
torrentBase64 = await this.readSavedTorrentBase64(metadataDir)
if (this.stopped) return
} catch (err) {
sourceError = err
}
}
if (torrentBase64 === undefined && pair.task.torrentMetaPath) {
try {
const bytes = await readFile(pair.task.torrentMetaPath)
torrentBase64 = bytes.toString('base64')
if (this.stopped) return
} catch (err) {
sourceError = err
}
}
if (torrentBase64 === undefined) {
throw new AppError(
ErrorCode.MagnetResolveFailed,
`saved torrent metadata is no longer available for task ${taskId}`,
sourceError
)
}
const meta = await this.torrentParser.parse(torrentBase64)
if (this.stopped) return
this.eventBus.emit(Events.MagnetFileSelection, {
taskId,
meta,
magnetUri,
torrentBase64,
saveDir,
})
log.info({ taskId }, 'magnet file selection reopened')
}
View on GitHub (pinned to 1a708ee577)
Solutions
- Re-acquire the magnet metadata (re-add the magnet URI to re-resolve) since the saved file is unrecoverable.
- Move the metadata store to a stable, non-temp directory that survives reboots.
- Confirm the metadataDir volume is mounted before re-opening selection.
- Treat the task as unrecoverable for selection and inform the user to re-add.
Example fix
// before
if (torrentBase64 === undefined) {
throw new AppError(ErrorCode.MagnetResolveFailed, `saved torrent metadata is no longer available for task ${taskId}`, sourceError)
}
// after — attempt re-resolution from the magnet URI before failing
if (torrentBase64 === undefined) {
if (pair.task.magnetUri) {
return this.reresolveMetadata(pair.task.magnetUri, taskId)
}
throw new AppError(ErrorCode.MagnetResolveFailed, `saved torrent metadata is no longer available for task ${taskId}`, sourceError)
} Defensive patterns
Strategy: fallback
Validate before calling
async function metadataRecoverable(fs, torrentMetaPath) {
if (!torrentMetaPath) return false
try { await fs.access(torrentMetaPath, fs.constants.R_OK); return true } catch { return false }
} Type guard
function isMagnetResolveFailed(e) { return e instanceof AppError && e.code === ErrorCode.MagnetResolveFailed } Try / catch
if (torrentBase64 === undefined) {
if (pair.task.magnetUri) {
return this.reresolveMetadata(pair.task.magnetUri, taskId) // fallback: re-resolve
}
throw new AppError(ErrorCode.MagnetResolveFailed, `saved torrent metadata is no longer available for task ${taskId}`, sourceError)
} Prevention
- Store magnet sidecars in a stable, non-temp dir that survives reboots.
- Keep an in-memory cache warm for MetadataReady tasks until selection completes.
- Confirm the metadataDir volume is mounted before re-opening selection.
- If unrecoverable, inform the user to re-add the magnet URI.
When it happens
Trigger: The metadata cache entry was evicted AND the `.torrent` sidecar at torrentMetaPath was deleted/cleared (OS reboot wiped the temp dir, user cleaned the dir, disk error); torrentMetaPath points to an unmounted removable volume.
Common situations: OS reboot cleared the temp metadataDir; antivirus removed the `.torrent`; metadataDir moved/changed between runs; user manually deleted sidecars; storage failure.
Related errors
- TaskCreateTorrentMetaFailed
- TaskFinalizeRenameFailed
- TaskFinalizeMetaMissing
- TaskFinalizeMetaMissing
- TaskCreateDedupExhausted
AI-assisted analysis of agalwood/Motrix@1a708ee577 (2026-08-12).
Data as JSON: /api/errors/89a2208160831d19.
Report an issue: GitHub.