Prevent Files tab lockup when readdir fails

renderDirectory sets renderingDirectory=true then awaits puter.fs.readdir
with no error handling. readdir rejects on any backend error (permission,
deleted directory, network), leaving renderingDirectory stuck true so the
re-entry guard blocks all future navigation and the spinner never clears.
Catch the rejection and reset state.
This commit is contained in:
jelveh
2026-07-16 18:42:43 -07:00
parent dec62b116a
commit e01d747b52
+12 -1
View File
@@ -1811,7 +1811,18 @@ const TabFiles = {
const readdirArg = isPath
? { path: target, consistency: options.consistency || 'eventual' }
: { uid: target, consistency: options.consistency || 'eventual' };
let directoryContents = await window.puter.fs.readdir(readdirArg);
let directoryContents;
try {
directoryContents = await window.puter.fs.readdir(readdirArg);
} catch ( err ) {
// readdir rejects on any backend error (permission, deleted dir,
// network). Without this, renderingDirectory would stay true and
// the guard above would block all further navigation.
console.error('Failed to read directory:', err);
this.hideSpinner();
this.renderingDirectory = false;
return;
}
if ( ! directoryContents ) {
this.hideSpinner();
this.renderingDirectory = false;