Skip to content
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

Function names are not printed when use console.trace() #12

Open
Natalia-Hristova opened this issue Nov 18, 2019 · 1 comment
Open

Function names are not printed when use console.trace() #12

Natalia-Hristova opened this issue Nov 18, 2019 · 1 comment
Assignees
Labels
bug Something isn't working ready for test

Comments

@Natalia-Hristova
Copy link

  1. Run tns create AppJS --js
  2. Add console.trace();
  3. Run tns debug ios and open the URL in Chrome

Actual:

at <anonymous> (file:///app/bundle.js:286:17)
at <anonymous> (file:///app/vendor.js:3620:32)
at <anonymous> (file:///app/vendor.js:3640:18)
at <anonymous> (file:///app/vendor.js:15540:19)

Here's how it looks in android:

main-view-model.js:40 Trace
at viewModel.onTap (file:///data/data/org.nativescript.AppDebugJS/files/app/bundle.js:294:17)
at push.../node_modules/@nativescript/core/data/observable/observable.js.Observable.notify (file:///data/data/org.nativescript.AppDebugJS/files/app/vendor.js:3537:32)
at push.../node_modules/@nativescript/core/data/observable/observable.js.Observable._emit (file:///data/data/org.nativescript.AppDebugJS/files/app/vendor.js:3557:18)
at ClickListenerImpl.onClick (file:///data/data/org.nativescript.AppDebugJS/files/app/vendor.js:14715:23)
@darind
Copy link
Collaborator

darind commented Nov 19, 2019

The full file paths are pretty long on iOS and are intentionally stripped as it makes stacktraces harder to read.

Consider this:

at <anonymous> (file:///var/containers/Bundle/Application/94891CB2-71B9-4DF6-99FB-742E82210A7A/TestRunner.app/app/index.js:6:17)
at test (file:///var/containers/Bundle/Application/94891CB2-71B9-4DF6-99FB-742E82210A7A/TestRunner.app/app/index.js:8:21)
at <anonymous> (file:///var/containers/Bundle/Application/94891CB2-71B9-4DF6-99FB-742E82210A7A/TestRunner.app/app/index.js:9:3)
at require (VM)

In contrast to this:

at <anonymous> (file:///app/index.js:6:17)
at test (file:///app/index.js:8:21)
at <anonymous> (file:///app/index.js:9:3)
at require (VM)

On the other hand we have an issue that prevents the runtime from properly collecting function names in stack traces. Notice the <anonymous> names in the stacktrace.

Let's consider the following example:

(function test() {
    const viewModel = new Object();
    viewModel.onTap = () => { console.trace("ok"); };
    viewModel.onTap.apply(viewModel, []);
})();

Which produces:

at <anonymous> (file:///app/index.js:6:17)
at test (file:///app/index.js:8:21)
at <anonymous> (file:///app/index.js:9:3)
at require (VM)

instead of the expected:

at viewModel.onTap (file:///app/index.js:6:17)
at test (file:///app/index.js:8:21)
at <anonymous> (file:///app/index.js:9:3)
at require (VM)

@darind darind self-assigned this Nov 19, 2019
@darind darind added the bug Something isn't working label Nov 19, 2019
@Natalia-Hristova Natalia-Hristova changed the title Files' path is not printed when use console.trace() Function names are not printed when use console.trace() Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready for test
Projects
None yet
Development

No branches or pull requests

2 participants