mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 23:20:46 +00:00
- Fix per-client dedup: store _reopeningPromise on client object instead of module-level global to prevent cross-session confusion - Narrow isSessionError patterns: replace overly broad "not found" and "closed" with specific "channel closed"/"connection closed", add "timed out" for channel open timeout errors - Prevent channel leak on timeout: close orphaned SFTP channel when tryOpenSftpChannel callback fires after timeout - Auto-reload directory listing after successful reconnect in SFTP modal to avoid stale UI state
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
export const isSessionError = (err: unknown): boolean => {
|
|
if (!(err instanceof Error)) return false;
|
|
const msg = err.message.toLowerCase();
|
|
return (
|
|
msg.includes("session not found") ||
|
|
msg.includes("sftp session") ||
|
|
msg.includes("session lost") ||
|
|
msg.includes("channel not ready") ||
|
|
msg.includes("readdir is not a function") ||
|
|
msg.includes("channel closed") ||
|
|
msg.includes("connection closed") ||
|
|
msg.includes("connection reset") ||
|
|
msg.includes("write after end") ||
|
|
msg.includes("no response") ||
|
|
msg.includes("not connected") ||
|
|
msg.includes("client disconnected") ||
|
|
msg.includes("timed out")
|
|
);
|
|
};
|
|
|
|
/**
|
|
* Check if an error message indicates a fatal error that should stop the entire upload.
|
|
* This includes session errors AND target directory deletion errors.
|
|
*/
|
|
export const isFatalUploadError = (errorMessage: string): boolean => {
|
|
// Reuse isSessionError for session-related checks
|
|
const asError = new Error(errorMessage);
|
|
if (isSessionError(asError)) return true;
|
|
|
|
const msg = errorMessage.toLowerCase();
|
|
return (
|
|
// Connection-related (broader than session errors)
|
|
msg.includes("connection") ||
|
|
// Target directory was deleted during upload
|
|
msg.includes("no such file") ||
|
|
msg.includes("enoent") ||
|
|
msg.includes("does not exist") ||
|
|
msg.includes("write stream error") ||
|
|
// Directory was removed
|
|
msg.includes("directory not found") ||
|
|
msg.includes("not a directory")
|
|
);
|
|
};
|