Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

javascript errors sometimes get swallowed when inspector is running on reload #24

Closed
ryanzec opened this issue Feb 12, 2017 · 7 comments
Labels

Comments

@ryanzec
Copy link

ryanzec commented Feb 12, 2017

Issue Summary

In chrome on Mac OS X, when I have the inspector opened and I reload the page and there is an error in my server code, I don't see it however it I have the inspector closed and then reload the page and open the inspector, the error show up in the console log.

Expected Behavior

I should see my server error in the console regardless if the inspector is opened

Current Behavior

In chrome on Mac OS X, when I have the inspector opened and I reload the page and there is an error in my server code, I don't see it however it I have the inspector closed and then reload the page and open the inspector, the error show up in the console log.

Steps to Reproduce

Create a server file with a javascript error in it.

Environment

  • Browser: Chrome
  • Version of service-mocker: 1.0.3
@idiotWu
Copy link
Member

idiotWu commented Feb 12, 2017

What's the error message?

@ryanzec
Copy link
Author

ryanzec commented Feb 12, 2017

The error is in my own code:

Uncaught TypeError: Cannot read property 'number' of undefined

I am just not able to see it unless I close and reopen the inspector.

@idiotWu
Copy link
Member

idiotWu commented Feb 12, 2017

Sorry I couldn't reproduce this issue with my own code. Would you be so kind as to create a repo that reproduce this issue?

@ryanzec
Copy link
Author

ryanzec commented Feb 12, 2017

well it is something that is hard to reproduce, I cleared my cache (which seemly got rid of the error that was happening and now I am see error in the inspector.

I seem to be getting errors when my code is fine and the only thing I can think of in that I am using webpack to generate my server.js file using this config:

{
  module: {
    loaders: [{
      test: /\.js$/,
      loader: 'babel',
      exclude: [
        path.resolve(__dirname, "node_modules")
      ],
      query: {
        presets: ['react', 'es2015-without-strict-loose'],
        plugins: ['static-fs']
      }
    }, {
      test: /\.json$/,
      loader: 'json-loader'
    }]
  },
  entry: {
    '/javascript/mocker/server': './web/app/mocker/server.js'
  },
  devtool: ['source-map'],
  output: {
    path: './web/build',
    publicPath: '/build',
    filename: '[name].js'
  }
}

Is there any reason why I would not be able to use webpack to build my server.js file?

@ryanzec
Copy link
Author

ryanzec commented Feb 12, 2017

well the second time was my fault though not sure about the original issue I reported. I have noticed weird flaky issues when I have had errors my my server.js code and just wanted to mention it (clearer the cache enough times seems to fix it). I know it is hard to debug and flaky issue so I guess you can just close this and then I can re-open / open another if I am able to more reliability able to re-produce the issue.

@idiotWu
Copy link
Member

idiotWu commented Feb 12, 2017

Ah, I got this issue too.

This is because the error is fired during last run. Once the page is reloaded, you won't see the error again unless you repeat the same action that caused it. In other words, the error you see after reopening console in chrome is a kind of outdated message which is not relative to current window context, chrome throws it again just for debugging purpose. You can switch to the Application tab of chrome dev tool to see all error messages in current service worker context.

You can imagine it like you get a runtime error in console (maybe by clicking a button), then you reload the page and the error message is gone because you haven't fired it.

I think we might have nothing to do with this issue, it's just a supposed behavior in chrome as well as other browsers which support service workers. If you retry the same action that causes the failure, you will be able to see it right away in console.


Update: Firefox doesn't seem to throw the old error message after reopening console.

@idiotWu
Copy link
Member

idiotWu commented Feb 12, 2017

A screencast reproduces this issue:

sw

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants