Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable viewer websocket connection if mode is static #215

Merged
merged 1 commit into from Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion client/viewer.jsx
Expand Up @@ -9,7 +9,9 @@ import styles from './viewer.css';
// Initializing WebSocket for live treemap updates
let ws;
try {
ws = new WebSocket(`ws://${location.host}`);
if (window.enableWebSocket) {
ws = new WebSocket(`ws://${location.host}`);
}
} catch (err) {
console.warn(
"Couldn't connect to analyzer websocket server so you'll have to reload page manually to see updates in the treemap"
Expand Down
6 changes: 4 additions & 2 deletions src/viewer.js
Expand Up @@ -52,7 +52,8 @@ async function startServer(bundleStats, opts) {
res.render('viewer', {
mode: 'server',
get chartData() { return JSON.stringify(chartData) },
defaultSizes: JSON.stringify(defaultSizes)
defaultSizes: JSON.stringify(defaultSizes),
enableWebSocket: true
});
});

Expand Down Expand Up @@ -130,7 +131,8 @@ function generateReport(bundleStats, opts) {
mode: 'static',
chartData: JSON.stringify(chartData),
assetContent: getAssetContent,
defaultSizes: JSON.stringify(defaultSizes)
defaultSizes: JSON.stringify(defaultSizes),
enableWebSocket: false
},
(err, reportHtml) => {
if (err) return logger.error(err);
Expand Down
1 change: 1 addition & 0 deletions views/viewer.ejs
Expand Up @@ -13,6 +13,7 @@
<script>
window.chartData = <%- chartData %>;
window.defaultSizes = <%- defaultSizes %>;
window.enableWebSocket = <%- enableWebSocket %>;
</script>
</body>
</html>