Skip to content

Commit

Permalink
describe what happens if a timeout happens
Browse files Browse the repository at this point in the history
  • Loading branch information
scytacki committed Sep 26, 2024
1 parent 0766c57 commit 20fe7bb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/models/history/tree-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,20 @@ async function prepareFirestoreHistoryInfo(
}
});
timeoutId = setTimeout(() => {
// If there isn't a firestore metadata document in 2 seconds then give up
// If there isn't a firestore metadata document in 5 seconds then give up
disposer();
console.warn("Could not find metadata document to attach history to", documentPath);

Check warning on line 644 in src/models/history/tree-manager.ts

View check run for this annotation

Codecov / codecov/patch

src/models/history/tree-manager.ts#L643-L644

Added lines #L643 - L644 were not covered by tests
resolve();
// TODO: how should we handle this error?
}, 2000);
// If there is an error here the history will not be saved for the duration
// of this CLUE session.
// This happens because the rejection will bubble up to completeHistoryEntry.
// That does not handle errors from this promise. The "then" function will
// not be called. The error should be printed as an unhandled promise error.
// The next time a history entry is "completed" this rejected promise
// will be "then'd" again which will again not run its function.
// TODO: consider updating this to create the metadata document itself by
// calling createFirestoreMetadataDocument.
reject(`Could not find metadata document to attach history to ${documentPath}`);

Check warning on line 654 in src/models/history/tree-manager.ts

View check run for this annotation

Codecov / codecov/patch

src/models/history/tree-manager.ts#L654

Added line #L654 was not covered by tests
}, 5000);
});

const lastHistoryEntry = await getLastHistoryEntry(firestore, documentPath);
Expand Down

0 comments on commit 20fe7bb

Please sign in to comment.