Source-maps missing in dev builds
See original GitHub issueCurrent Behavior
I’m testing out building an app with Kotlin, and compiling sources to JS. Everything seems to be working really well with haul, except for stack-traces. I can debug kotlin sources, and everything. I just see this “can’t symbolocate error” every time I see a crash:
GET /index.android.bundle 200 11019287 - 12.494 ms
POST /symbolicate 404 151 - 0.214 ms
POST /symbolicate 404 151 - 0.141 ms
If I watch the logs, I see the following:
01-20 22:31:23.555 1925 15179 E ReactNativeJS: TypeError: Object.freeze can only be called on Objects.
01-20 22:31:23.555 1925 15179 E ReactNativeJS:
01-20 22:31:23.555 1925 15179 E ReactNativeJS: This error is located at:
01-20 22:31:23.555 1925 15179 E ReactNativeJS: in HelloWorld (at renderApplication.js:35)
01-20 22:31:23.555 1925 15179 E ReactNativeJS: in RCTView (at View.js:71)
01-20 22:31:23.555 1925 15179 E ReactNativeJS: in View (at AppContainer.js:102)
01-20 22:31:23.555 1925 15179 E ReactNativeJS: in RCTView (at View.js:71)
01-20 22:31:23.555 1925 15179 E ReactNativeJS: in View (at AppContainer.js:122)
01-20 22:31:23.555 1925 15179 E ReactNativeJS: in AppContainer (at renderApplication.js:34)
01-20 22:31:23.567 1925 15179 E ReactNativeJS: TypeError: Object.freeze can only be called on Objects.
01-20 22:31:23.567 1925 15179 E ReactNativeJS:
01-20 22:31:23.567 1925 15179 E ReactNativeJS: This error is located at:
01-20 22:31:23.567 1925 15179 E ReactNativeJS: in HelloWorld (at renderApplication.js:35)
01-20 22:31:23.567 1925 15179 E ReactNativeJS: in RCTView (at View.js:71)
01-20 22:31:23.567 1925 15179 E ReactNativeJS: in View (at AppContainer.js:102)
01-20 22:31:23.567 1925 15179 E ReactNativeJS: in RCTView (at View.js:71)
01-20 22:31:23.567 1925 15179 E ReactNativeJS: in View (at AppContainer.js:122)
01-20 22:31:23.567 1925 15179 E ReactNativeJS: in AppContainer (at renderApplication.js:34)
01-20 22:31:23.575 1925 15179 W ReactNativeJS: Unable to symbolicate stack trace: JSON Parse error: Unrecognized token '<'
01-20 22:31:23.577 1925 15179 W ReactNativeJS: Unable to symbolicate stack trace: JSON Parse error: Unrecognized token '<'
Expected Behavior
My stack-traces would be able to be symbolicated just fine.
Haul Configuration (webpack.haul.js)
module.exports = ({ platform }, defaults) => ({
entry: `./index.js`,
module: {
...defaults.module,
rules: [
...defaults.module.rules,
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
}
]
}
});
Your Environment
| software | version |
|---|---|
| Haul | 1.0.0-beta.12 |
| react-native | 0.52 |
| node | 9.4.0 |
| npm or yarn | yarn 1.3.2 |
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:30 (17 by maintainers)
Top Results From Across the Web
Angular 12 source map is missing in browser - Stack Overflow
Angular 12 changed the default "ng build" to use the "production" configuration. You want "sourceMap" so try adding a "development" config ...
Read more >4 Reasons Why Your Source Maps are Broken - Sentry Blog
Missing or incorrect source map directive · Missing original source files · Bad source maps caused by multiple transformations · Files are ...
Read more >Source map errors — Firefox Source Docs documentation
The source map resource can be missing or inaccessible. Source map file is missing. The fix here is to make sure the file...
Read more >Sourcemaps not appearing in Browser UI
One of the source maps files you've uploaded, so we can review it and see if there may be something missing that's causing...
Read more >Advanced Features: Source Maps | Next.js
Source Maps are enabled by default during development. During production builds, they are disabled to prevent you leaking your source on the client, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Hmm,
devtool: 'eval-*'is equivalent to the currentplugins: [new EvalSourceMapDevToolPlugin()]. It looks like the root of the issue is that before #289 non-bundle builds generated both eval and external source maps - eval required for remote debugging, external for symbolicate. This isn’t an ideal state either, but see below. (On the other hand, it probably shouldn’t be addingSourceMapDevToolPluginanddevtool: 'source-mapwhen bundling, since the latter adds the former)When remote debugging, the code is actually running in the debugger: e.g. Chrome or React Native Debugger, all the JS<->Native communication is remoted over the debugger connection(!), and chrome can look up source maps when generating an error stack itself. But when running inside RN’s embedded JavaScriptCore runtime, it doesn’t have access to source maps, so it delegates to the packager via
symbolicate. So whatever is done needs to work in both. I assume you don’t get stacks when not remote debugging because of this issue: the symbolicate call is 404ing? But be awareconsole.errors()will redbox without a stack, and I think that’s used by some of the react-native polyfill / shims?I’m not part of the team, but I would guess a PR should have:
haul bundlesize does not increase dramaticallySo I guess start experimenting, reading up on https://webpack.js.org/plugins/source-map-dev-tool-plugin/ etc.? This stuff is tricky.
Don’t focus on this, but it would be cool if chrome workspace support worked too - for that the
moduleFilenameTemplateshould create files likefile:///C:/path/to/fileon windows,file:///path/to/fileon nix…, see howcreate-react-appdoes it in dev - though in prod they make the url relative for I assume consistency across build machines.Just saw the following error while debugging an exception I created to repro this issue:
The sourcemaps are definitely there. I’m able to see all the kotlin sources in chrome, and also set breakpoints, even on the line that throws an exception. I’ll work on creating a reproducible example project.