Skip to content

Commit

Permalink
Chore: Add console logging to better debug hanging preview (#93)
Browse files Browse the repository at this point in the history
- In rare cases, Preview will hang on "Generating Preview..." without viewer static assets having been loaded
- This means Preview is failing somewhere between handleLoadResponse() and the appropriate viewer's load() being called
- We add logging in 3 places that could potentially be causing this
  • Loading branch information
tonyjin authored and Jeremy Press committed Apr 25, 2017
1 parent ab5c65a commit 3e6299b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,9 @@ class Preview extends EventEmitter {
handleLoadResponse(file) {
// If preview is closed or response comes back for an incorrect file, don't do anything
if (!this.open || (this.file && this.file.id !== file.id)) {
/* eslint-disable no-console */
console.error(`handleLoadResponse returned early - this.open: ${this.open}, this.file: ${this.file}, this.file.id: ${this.file.id}, file.id: ${file.id}`);
/* eslint-enable no-console */
return;
}

Expand Down Expand Up @@ -804,6 +807,10 @@ class Preview extends EventEmitter {
if (shouldLoadViewer) {
this.logger.setCacheStale();
this.loadViewer();
} else {
/* eslint-disable no-console */
console.error(`shouldLoadViewer was false - cachedFile: ${cachedFile}, checkFileValid: ${checkFileValid(cachedFile)}, cachedFile.file_version.sha1: ${cachedFile.file_version.sha1}, file.file_version.sha1: ${file.file_version.sha1}, isWatermarked: ${isWatermarked}`);
/* eslint-enable no-console */
}
} catch (err) {
this.triggerError((err instanceof Error) ? err : new Error(__('error_refresh')));
Expand All @@ -820,6 +827,9 @@ class Preview extends EventEmitter {
loadViewer() {
// If preview is closed don't do anything
if (!this.open) {
/* eslint-disable no-console */
console.error(`loadViewer returned early - this.open: ${this.open}`);
/* eslint-enable no-console */
return;
}

Expand Down

0 comments on commit 3e6299b

Please sign in to comment.