question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't debug with Chrome

See original GitHub issue

Current Behavior

When debugging with Chrome, the debugger does not show the scripts from webpack in the sources tab.

current

Expected Behavior

Source files are shown in the sources tab and it is possible to place breakpoints and debug the code, i.e.:

expected

Haul Configuration (webpack.haul.js)

var webpack = require('webpack');

module.exports = ({ platform }, { module, resolve, plugins }) => ({
  entry: `./src/index.${platform}.tsx`,
  module: {
    ...module,
    rules: [
      {
        test: /\.tsx?$/,
        use: [
          'babel-loader',
          'ts-loader'
        ]
      },
      ...module.rules
    ]
  },
  resolve: {
    ...resolve,
    extensions: [
      '.ts',
      '.tsx',
      `.${platform}.ts`,
      '.native.ts',
      `.${platform}.tsx`,
      '.native.tsx',
      ...resolve.extensions
    ]
  },
  plugins: [
    ...plugins,
    new webpack.optimize.ModuleConcatenationPlugin()
  ]
});
software version
Haul 1.0.0-beta.4
react-native 0.47.1
node 7.9.0
npm or yarn 5.3.0

Other Information

While attempting to resolve this issue, I found that the file debuggerWorker.js is loading the app file using fetch, replacing 'this["webpackHotUpdate"]' with 'self["webpackHotUpdate"]' and then evaling it.

While this works (as in, the app works), I believe Chrome doesn’t understand that the files loaded through fetch should be added as source files.

I tried replacing the line

fetch(message.url).then(resp => resp.text()).then(evalJS);

with

try {
  importScripts(message.url);
} catch (e) {
  self.ErrorUtils.reportFatalError(e);
} finally {
  self.postMessage({ replyID: message.id });
  processEnqueuedMessages();
}

but this just left a blank screen. I had to use the following for it to actually work:

var error;
try {
  importScripts(message.url);
} catch (e) {
  error = e;
}
processEnqueuedMessages();
sendReply(null, error);

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
zamotanycommented, Aug 4, 2017

Try adding devtool: 'eval-source-map', to webpack.haul.js.

0reactions
springHyccommented, Aug 24, 2017

@zamotany

Try adding devtool: ‘eval-source-map’, to webpack.haul.js. 添加这个之后,文件是不换行的,由于文件不换行,所以没有办法对文件中的某一行代码设置断点。

我按照source maps这个里面添加了: webpack.parts.js:

exports.generateSourceMaps = ({ type }) => ({
  devtool: type,
});

webpack.config.js:

const productionConfig = merge([

  parts.generateSourceMaps({ type: 'source-map' }),

  ...
]);

const developmentConfig = merge([

  {
    output: {
      devtoolModuleFilenameTemplate: 'webpack:///[absolute-resource-path]',
    },
  },
  parts.generateSourceMaps({ type: 'cheap-module-eval-source-map' }),

  ...
]);

并且将webpack.haul.js中设置为

module.exports = ({ platform }, defaults) => ({
  entry: `./index.${platform}.js`,
  devtool: 'eval-source-map', // eval-source-map
});

仍然是显示一行,不能对文件中设置断点调试

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot debug with chrome - Visual Studio Feedback
- Enable javascript debugging for ASP.NET (Chrome and IE) to "True" - MVC Project with framework 4.5.2. Error message when press Debug (Triangle...
Read more >
Chrome javascript debugger breakpoints don't do anything?
For debugger to work the 'Disable Cache' needs to be set under the Network tab or you will be running the cached code....
Read more >
Debugging in the browser - The Modern JavaScript Tutorial
Before writing more complex code, let's talk about debugging. Debugging is the process of finding and fixing errors within a script.
Read more >
Cannot debug with Chrome DevTools · Issue #583 - GitHub
When trying to debug Node.js code run with Sucrase, the Chrome DevTools can't find the source code because they look in the wrong...
Read more >
Issues: Find and fix problems - Chrome Developers
# Open the Issues tab · Visit a page with issues to fix, such as samesite-sandbox.glitch.me. · Open DevTools. · Click the Open...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found