Reputation: 1680
When we have JS errors in our production environment, it's close to impossible to identify where the error is located because all of the files are compressed. Are there any best practices when pushing to production, but yet still having a reliable line items to refer to when an error occurs?
Upvotes: 1
Views: 3185
Reputation: 21030
Ideally, you should not be debugging in production. But, in rare scenarios, you may need to debug client-side code for any uncaught JS error. Following are the steps if you have to do production debugging:
source-maps
. So when you are bundling for production, make sure that you are generating them using Webpack devtool
property set to source-map
. Read more on Webpack website..map
extension. These files should be blocked in the production environment. Whenever browser Dev tools are opened, browsers try to pull source-maps. Ideally, your server should block requests to source-maps.source-maps
. It could be enabled via cookies. When the application is being loaded, you can add this as query params, JavaScript will pick it up and set it as a header or cookie.Once, your issue is identified, you should again block serving of source-maps.
Upvotes: 2