Skip to content

Issues with source maps #18050

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

Closed
DartBot opened this issue Apr 5, 2014 · 10 comments
Closed

Issues with source maps #18050

DartBot opened this issue Apr 5, 2014 · 10 comments
Assignees
Labels
closed-obsolete Closed as the reported issue is no longer relevant dart2js-sourcemap type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@DartBot
Copy link

DartBot commented Apr 5, 2014

This issue was originally filed by [email protected]


What steps will reproduce the problem?

  1. Create a sample Dart application (call it "debug")
  2. Add "throw new Exception('boom!');" to the reverseText method
  3. Launch the application with "Run as JavaScript" and Chrome or Firefox

When the error occurs, the console reports it with a reference to debug.dart.js:2791
So I looked inside the build\web directory of the project and saw, that the generated JS files (debug.dart.precompiled.js and debug.dart.js) had no link to the source map file (debug.dart.js.map). So:

  1. Add "//# sourceMappingURL=debug.dart.js.map" at the end of both debug.dart.precompiled.js and debug.dart.js
  2. Clear browser cache and reload the application

Now the console referrs to some strange js_helper.dart:1081

This doesn't seem right! I expect a reference to the place in the original code = "throw new Exception('boom!');" in the reverseText method.

What version of the product are you using? On what operating system?

  • Dart Editor version 1.2.0.release (STABLE) & Dart SDK version 1.2.0
  • Chrome 33.0.1750.154 | Firefox 28
  • Win7 x64

Can someone reproduce/confirm the issue or tell me what am I doing wrong?

@DartBot
Copy link
Author

DartBot commented Apr 6, 2014

This comment was originally written by @Fox32


The missing source map reference is already fixed in the DEV builds, see Issue #15563.

@DartBot
Copy link
Author

DartBot commented Apr 6, 2014

This comment was originally written by [email protected]


Yes, with Dart Editor version 1.3.0.dev_07_10 (DEV) & Dart SDK version 1.3.0-dev.7.10 the source map is linked and the console error message refers to js_helper.dart:1187. But this is still not the correct place in the original code!..

@kevmoo
Copy link
Member

kevmoo commented Apr 8, 2014

cc @munificent.
Added Area-Pub, Pub-Build, Triaged labels.

@nex3
Copy link
Member

nex3 commented Apr 8, 2014

This is definitely not a pub issue. The source map exists and is being read by the browser; it's just not directing to the location the user expects.


Removed Area-Pub, Pub-Build labels.
Added Area-Dart2JS label.

@munificent
Copy link
Member

This definitely will not work on 1.2 stable. Like you note, the source map reference is missing and the paths are wrong.

It should work on the latest 1.3 dev builds. This may be a pub issue. Pub has a lot of control over what paths dart2js thinks it's using to find the SDK. Can you give me a very precise set of steps to repro?

Ideally, a .zip of a package I can try this on, but if it's simple enough just write it out here. What I want to know in particular is how the files in your package are organized. That will help me track down what's going on here.

Thanks!


Set owner to @munificent.
Removed Area-Dart2JS label.
Added Area-Pub label.

@DartBot
Copy link
Author

DartBot commented Apr 8, 2014

This comment was originally written by [email protected]


Here's the zipped project folder.
What "very precise set of steps" should I provide? - I thought I wrote everything above already. But if you still miss something - just let me know.


Attachment:
debug.zip (88.75 KB)

@munificent
Copy link
Member

Added Started label.

@munificent
Copy link
Member

Ah, OK. Now I have a clearer picture of what's going on. Sorry, I didn't read your initial report correctly. I thought it couldn't find js_helper.dart. Your issue is that the source map is working, it just doesn't point to the code you want.

This is indeed a dart2js issue. Pub is taking you to the file that the source map says it should. It's just that thrown exceptions seem to point to an unhelpful location.


Removed Area-Pub label.
Added Area-Dart2JS, Triaged labels.

@floitschG
Copy link
Contributor

Set owner to @johnniwinther.

@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
@sigmundch
Copy link
Member

Note this is still an issue. This is likely related to having holes in the source-map.

Johnni, here are two simple tests to make this easier to reproduce.

Test 1: adapted from the original one.

a.html:

<body><script src=out.js defer></script>

input.dart:

import 'dart:html';

void main() {
  new DivElement()
      ..onClick.listen(reverseText)
      ..click();

}

void reverseText(MouseEvent event) {
  throw new Exception('boom!');
}

The stack trace looks like:

Uncaught Error: Exception: boom!
    at Object.wrapException (out.js:705)
    at StaticClosure.reverseText (out.js:2985)
    at _EventStreamSubscription_closure.call$1 (out.js:6816)
    at invokeClosure_closure0.call$0 (out.js:4270)
    at _IsolateContext.eval$1 (out.js:3515)
    at Object._callInIsolate (out.js:248)
    at invokeClosure (out.js:889)
    at HTMLDivElement.<anonymous> (out.js:908)
    at Element.click$0 (out.js:6702)
    at StaticClosure.main (out.js:2982)

The relevant output looks like this:

2984:    reverseText: function($event) {
2985:      throw H.wrapException(P.Exception_Exception("boom!"));

Note that there are no columns on the stack trace. We don't seem to have entries for most of the body of reverseText. If I request column '2985:51' we do find the reverseText location, but we don't if I ask for '2985:0' or '2985:7' (where the throws is)

Test 2: simplified even further to only use streams and no dart:html. This reproduces the problem in d8:

import 'dart:async';

void main() {
  new Stream.fromFuture(new Future(() {})).listen(boom);
}

void boom(_) {
  throw new Exception('boom!');
}

The stack trace is:

sdk/lib/_internal/js_runtime/lib/preambles/d8.js:263: Exception: boom!
          throw e;
          ^
Exception: boom!
    at Object.H.wrapException (out.js:691:17)
    at D.boom (out.js:2610:15)
    at _RootZone.P._RootZone.runUnaryGuarded$2 (out.js:5514:18)
    at _ControllerSubscription.P._BufferingStreamSubscription._sendData$1 (out.js:5136:18)
    at _ControllerSubscription.P._BufferingStreamSubscription._async$_add$1 (out.js:5086:14)
    at _SyncStreamControllerDispatch.P._SyncStreamControllerDispatch._sendData$1 (out.js:4975:32)
    at _SyncStreamControllerDispatch.P._StreamController._async$_add$1 (out.js:4898:14)
    at closure.P.closure.call$1 (out.js:4807:10)
    at _RootZone.P._RootZone.runUnary$2 (out.js:5558:18)
    at _FutureListener.P._FutureListener.handleValue$1 (out.js:4433:32)

Using the backwards lookup, we get this:

wrapException       js_helper.dart 1742:17
no mapping                              

@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-obsolete Closed as the reported issue is no longer relevant dart2js-sourcemap type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

8 participants