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

when flutter is run on browser , it has lot of extra stack trace strings which get printed everytime. #40

Closed
nateshmbhat opened this issue Mar 17, 2020 · 13 comments

Comments

@nateshmbhat
Copy link

nateshmbhat commented Mar 17, 2020

Right now , on flutter web , it gives error saying :

│ package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 248:20  get current
js_primitives.dart:32 │ package:logger/src/printers/pretty_printer.dart 89:53                                 log
js_primitives.dart:32 │ package:logger/src/logger.dart 124:29                                                 log
js_primitives.dart:32 │ package:logger/src/logger.dart 85:5                                                   d
js_primitives.dart:32 │ package:core/common_modules/logger.dart 26:63                                         d
js_primitives.dart:32 │ package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 47:50            onValue
js_primitives.dart:32 │ package:dart-sdk/lib/async/zone.dart 1381:54                                          runUnary
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 140:18                                    handleValue
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 682:44                                    handleValueCallback
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 711:32                                    _propagateToListeners
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 526:5                                     [_completeWithValue]
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 556:7                                     callback
js_primitives.dart:32 │ package:dart-sdk/lib/async/schedule_microtask.dart 43:11                              _microtaskLoop
js_primitives.dart:32 │ package:dart-sdk/lib/async/schedule_microtask.dart 52:5                               _startMicrotaskLoop
js_primitives.dart:32 │ package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 168:15           <fn>

For every log its giving these errors. Please let us know of any workaround for this ....

@nateshmbhat
Copy link
Author

Please refer these issues :

flutter/flutter#37635
creativecreatorormaybenot/flutter@fc56607

@nateshmbhat nateshmbhat changed the title Add support for flutter web when flutter is run on browser , it has lot of extra stack trace strings which get printed everytime. Mar 19, 2020
@nateshmbhat
Copy link
Author

A fix might be adding a isFlutterWeb parameter to PrettyPrinter which will remove some of the flutter library and dart-sdk specific strings from the stacktrace only when run on web.

@haarts
Copy link
Collaborator

haarts commented Mar 26, 2020

I must have messed up my notifications settings and missed this issue. My apologies. I'll look into it tomorrow first thing.

@haarts
Copy link
Collaborator

haarts commented Mar 27, 2020

Could you help me out and provide me with a dead simple project which displays this behaviour, I have no experience with Flutter in the browser. Thank you!

@Cocotus
Copy link

Cocotus commented Apr 7, 2020

+1 A fix for this stacktraces poluting my logs in flutter web would be really nice ;) Seems @nateshmbhat has made a fix for this.
@haarts You can actually get this problem in any flutter web project you create I believe. You need to switch to flutter beta channel, activate web in flutter (theres a guide for that on flutter setup), so you can run any flutter app in chrome browser. Then you will get those stackmessages. I will test the fix later to see if it solves my problem.

@nateshmbhat
Copy link
Author

You can refer this guide to migrate to flutter web : https://cutt.ly/migrate-to-flutter-web

@haarts
Copy link
Collaborator

haarts commented Apr 20, 2020

I'm currently (finally) looking into this. It appears that the stacktrace has significant different formatting on devices vs web. Your PR does not work for me because the regexes do not match (I got these kind of lines: packages/logger/src/printers/pretty_printer.dart 91:37).

I'm devising a solution.

@haarts
Copy link
Collaborator

haarts commented Apr 21, 2020

Could you humour me and test this branch: https://github.com/leisim/logger/tree/deal-with-flutter-web-stacktraces?

The issue is that the stacktraces from both platforms are formatted differently. In the branch I created I took your ideas but I was able to avoid the additional boolean parameter to the constructor.

I can't reproduce the kind of stacktrace you have in your initial post, that worries me a bit. But together I'm sure we'll figure it out.

@Cocotus
Copy link

Cocotus commented Apr 21, 2020

Thanks for your efforts Mr. haarts! I will try to check this branch out this evening and report back

@Cocotus
Copy link

Cocotus commented Apr 21, 2020

I have tested it and it looks fine now!
What I did for testing:

  • Downloaded the new branch project.
  • Unzipped logger folder, openend in VSCode -> Get Packages. Missing packages errors went away.
  • Now I switched to example folder in VSCode. terminal input: cd "PathToExampleFolder"
  • Now I created necessary flutter web files. terminal input: flutter create .
  • Files were created in example folder with a new main.dart in "lib" folder. Now I overwrite this default main.dart that the flutter sdk created with the provided
    in the root of example folder to see some logs. :)
  • Now I got a missing logger reference error in the main.dart of example folder. To get rid of that, I added following 2 lines in pubspec.yaml of example project:
    logger:
    path: ../
  • No more errors after last step, so I run in terminal: flutter run -d chrome
  • Watch test result - small log in flutter web 😎
    Image of Yaktocat

In comparison I did the above steps for the current master branch with the following polluted logs in flutter web:
Image of Yaktocat

Looks fine too me! 🙂

@haarts
Copy link
Collaborator

haarts commented Apr 22, 2020

That is fantastic to hear! Thank you so much for the test and the step for step outline. You really went above and beyond.

I'll wrap this up then. @nateshmbhat I'll close your PR, thanks for the valuable contribution. Then I'll create a new release.

@haarts haarts closed this as completed Apr 22, 2020
@georgeman93
Copy link

I'm still getting this issue with v1.1.0 running on Chrome

I'll often get something like this instead of a stack trace to the relevant line number

│ #0   ../dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28                 get current
│ #1   ../packages/logger/src/printers/pretty_printer.dart 129:53                            log
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Expected a value of type 'String', but got one of type 'int'
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────```

@ugurberkecan
Copy link

ugurberkecan commented Dec 4, 2022

I'm still getting this issue with v1.1.0 running on Chrome

I'll often get something like this instead of a stack trace to the relevant line number

│ #0   ../dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28                 get current
│ #1   ../packages/logger/src/printers/pretty_printer.dart 129:53                            log
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Expected a value of type 'String', but got one of type 'int'
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────```

Do you know that can I remove lines I write below and also add file name at the beginning of │ ⛔ Expected a value of type 'String', but got one of type 'int ?

#0 ../dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28 get current
#1 ../packages/logger/src/printers/pretty_printer.dart 129:53 log

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

No branches or pull requests

5 participants