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

websocket does not establish under 'server' mode. #312

Closed
gaokun opened this issue Sep 20, 2019 · 2 comments
Closed

websocket does not establish under 'server' mode. #312

gaokun opened this issue Sep 20, 2019 · 2 comments

Comments

@gaokun
Copy link
Contributor

@gaokun gaokun commented Sep 20, 2019

Issue description

websocket does not establish under 'server' mode.

// yes, 'server' is default value of 'analyzerMode'
new BundleAnalyzerPlugin({analyzerMode: 'server'})

I am using webpack-bundle-analyzer as webpack plugin.

I have researched. This issue is related PR #215.

Testing

In below code, you can find that reporter.html uses enableWebSocket before setting.

viewer.jsx

console.log('use enableWebSocket', window.enableWebSocket);
// Initializing WebSocket for live treemap updates
let ws;
try {
  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"
  );
}

viewer.ejs

  <%- include('script', { filename: 'viewer.js' }) %>
  </head>
  <body>
    <div id="app"></div>
    <script>
      window.chartData = <%- escapeJson(chartData) %>;
      window.defaultSizes = <%- escapeJson(defaultSizes) %>;
      window.enableWebSocket = <%- escapeJson(enableWebSocket) %>;
      console.log('set Websocket', window.enableWebSocket);
    </script>

Test result in browser.

image

I am making a PR to fix it.

Technical info

  • Webpack Bundle Analyzer version: 3.5.0
  • Webpack version: 4.39.3
  • Node.js version: 10.15.3
  • npm/yarn version: 6.11.3
  • OS: MacOS
gaokun added a commit to gaokun/webpack-bundle-analyzer that referenced this issue Sep 20, 2019
@valscion
Copy link
Member

@valscion valscion commented Sep 20, 2019

Thanks for the detailed issue report. Left a review to the attached PR ☺️

@valscion
Copy link
Member

@valscion valscion commented Sep 20, 2019

Thanks for the contributions ☺️ The fix has been released in v3.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.