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

building with dart2js is causing strange error with package logging #31362

Closed
jimmyff opened this Issue Nov 13, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@jimmyff

jimmyff commented Nov 13, 2017

I've been using the logging package for months but suddenly I'm running in to issues with it when building with dart2js:

  js_helper.dart:1772 Uncaught Error: NoSuchMethodError: method not found: 'call$0' (message.call$0 is not a function)
    at Logger.log$5 (logging.dart:170)
    at Logger.log$4 (main.dart.js:172577)
    at logging.dart:218
    at _wrapJsFunctionForAsync_closure.$protected (async_patch.dart:213)
    at _wrapJsFunctionForAsync_closure.call$2 (async_patch.dart:237)
    at _awaitOnObject_closure.call$1 (async_patch.dart:187)
    at _RootZone.runUnary$2 (zone.dart:1371)
    at _Future__propagateToListeners_handleValueCallback.call$0 (future_impl.dart:129)
    at Object._Future__propagateToListeners (future_impl.dart:665)
    at _Future__addListener_closure.call$0 (future_impl.dart:343)

This is logging package code that the exception is pointing to:

 void log(Level logLevel, message,
      [Object error, StackTrace stackTrace, Zone zone]) {
    Object object;
    if (isLoggable(logLevel)) {
      if (message is Function) message = message();

I added some debug:

  void log(Level logLevel, message,
      [Object error, StackTrace stackTrace, Zone zone]) {
    Object object;
    print ('level: $logLevel message: ${message.toString()} is function: ${(message is Function).toString()}');
    print (message);
    if (isLoggable(logLevel)) {
      if (message is Function) message = message();

It seems that this is failing on the first time it's called. It prints the following to the console before it fails:

13:48:51.772 level: INFO message: endpoint:api.mydomain.com/v3.1/ hash:no is function: true
13:48:51.802 endpoint:api.mydomain.com/v3.1/ hash:no

It's very strange that is thinks this String is a Function - In Dartium there is no issue and it prints false when checking if the message is a function.

This is the code I use to make that first log call (this has worked for months up until last week):

  _log.info('endpoint:${config.api} hash:${config.hashRouting?'yes':'no'}');
@matanlurey

This comment has been minimized.

Show comment
Hide comment
@matanlurey

matanlurey Jun 19, 2018

Contributor

@jimmyff Consider trying the latest Dart2JS (with --preview-dart-2) and open if persists.

Contributor

matanlurey commented Jun 19, 2018

@jimmyff Consider trying the latest Dart2JS (with --preview-dart-2) and open if persists.

@matanlurey matanlurey closed this Jun 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment