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

Exception: NoSuchMethodError: The method 'pathFromUri' was called on null. #103

Open
ncb000gt opened this issue Jan 3, 2021 · 4 comments

Comments

@ncb000gt
Copy link

ncb000gt commented Jan 3, 2021

I'm running into issues running flutter test- sometimes it's successful and other times it's not. I'm wondering if anyone has any ideas as to whether this is an issue on my end or not. Thanks.


This is an example of the output.

Shell: [ERROR:flutter/shell/testing/tester_main.cc(302)] Unhandled exception
Shell: Exception: NoSuchMethodError: The method 'pathFromUri' was called on null.
Shell: Receiver: null
Shell: Tried calling: pathFromUri(Instance of '_SimpleUri')
Shell: Stack trace: #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
Shell: #1      Context.fromUri (package:path/src/context.dart:1006:19)
Shell: #2      Context.prettyUri (package:path/src/context.dart:1068:28)
Shell: #3      prettyUri (package:path/path.dart:458:34)
Shell: #4      Frame.library (package:stack_trace/src/frame.dart:105:12)
Shell: #5      Frame.location (package:stack_trace/src/frame.dart:119:14)
Shell: #6      Chain.toString.<anonymous closure>.<anonymous closure> (package:stack_trace/src/chain.dart:256:33)
Shell: #7      MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #8      ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #9      Chain.toString.<anonymous closure> (package:stack_trace/src/chain.dart:257:12)
Shell: #10     MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #11     ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #12     Chain.toString (package:stack_trace/src/chain.dart:258:8)
Shell: #13     LazyChain.toString (package:stack_trace/src/lazy_chain.dart:32:31)
Shell: #14     RemoteException.serialize (package:test_api/src/util/remote_exception.dart:51:48)
Shell: #15     RemoteListener._sendError (package:test_api/src/remote_listener.dart:158:32)
Shell: #16     RemoteListener.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:130:11)
Shell: #17     _rootRunBinary (dart:async/zone.dart:1222:13)
Shell: #18     _CustomZone.runBinary (dart:async/zone.dart:1107:19)
Shell: #19     runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1601:18)
Shell: #20     _CustomZone.handleUncaughtError (dart:async/zone.dart:1076:19)
Shell: #21     Future._propagateToListeners (dart:async/future_impl.dart:610:16)
Shell: #22     Future._completeError (dart:async/future_impl.dart:537:5)
Shell: #23     Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:593:7)
Shell: #24     _rootRun (dart:async/zone.dart:1190:13)
Shell: #25     _CustomZone.run (dart:async/zone.dart:1093:19)
Shell: #26     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
Shell: #27     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
Shell: #28     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
Shell: #29     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Shell:

I have put some logging in place and noticed that style is sometimes null during the execution, but not always which you can see below:
style.pathFromUri(_parseUri(uri))

flutter test test/integration-tests

00:02 +0: loading <path>/test/integration-tests/ui/apps/forgot_password_test.dart                                                                                                                                                                                         
STYLE: posix
00:03 +0: loading <path>/test/integration-tests/ui/apps/settings_test.dart                                                                                                                                                                                                
STYLE: posix
Shell: STYLE: null
Shell: [ERROR:flutter/shell/testing/tester_main.cc(302)] Unhandled exception
Shell: Exception: NoSuchMethodError: The method 'pathFromUri' was called on null.
Shell: Receiver: null
Shell: Tried calling: pathFromUri(Instance of '_SimpleUri')
Shell: Stack trace: #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
Shell: #1      Context.fromUri (package:path/src/context.dart:1006:19)
Shell: #2      Context.prettyUri (package:path/src/context.dart:1068:28)
Shell: #3      prettyUri (package:path/path.dart:458:34)
Shell: #4      Frame.library (package:stack_trace/src/frame.dart:105:12)
Shell: #5      Frame.location (package:stack_trace/src/frame.dart:119:14)
Shell: #6      Chain.toString.<anonymous closure>.<anonymous closure> (package:stack_trace/src/chain.dart:256:33)
Shell: #7      MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #8      ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #9      Chain.toString.<anonymous closure> (package:stack_trace/src/chain.dart:257:12)
Shell: #10     MappedListIterable.elementAt (dart:_internal/iterable.dart:417:31)
Shell: #11     ListIterable.fold (dart:_internal/iterable.dart:195:30)
Shell: #12     Chain.toString (package:stack_trace/src/chain.dart:258:8)
Shell: #13     LazyChain.toString (package:stack_trace/src/lazy_chain.dart:32:31)
Shell: #14     RemoteException.serialize (package:test_api/src/util/remote_exception.dart:51:48)
Shell: #15     RemoteListener._sendError (package:test_api/src/remote_listener.dart:158:32)
Shell: #16     RemoteListener.start.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:test_api/src/remote_listener.dart:130:11)
Shell: #17     _rootRunBinary (dart:async/zone.dart:1222:13)
Shell: #18     _CustomZone.runBinary (dart:async/zone.dart:1107:19)
Shell: #19     runZonedGuarded.<anonymous closure> (dart:async/zone.dart:1601:18)
Shell: #20     _CustomZone.handleUncaughtError (dart:async/zone.dart:1076:19)
Shell: #21     Future._propagateToListeners (dart:async/future_impl.dart:610:16)
Shell: #22     Future._completeError (dart:async/future_impl.dart:537:5)
Shell: #23     Future._asyncCompleteError.<anonymous closure> (dart:async/future_impl.dart:593:7)
Shell: #24     _rootRun (dart:async/zone.dart:1190:13)
Shell: #25     _CustomZone.run (dart:async/zone.dart:1093:19)
Shell: #26     _CustomZone.runGuarded (dart:async/zone.dart:997:7)
Shell: #27     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23)
Shell: #28     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
Shell: #29     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
Shell: 

Some additional info:
flutter doctor -v

flutter doctor -v
[✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale en-US)
    • Flutter version 1.22.5 at /Users/nick/Code/flutter
    • Framework revision 7891006299 (3 weeks ago), 2020-12-10 11:54:40 -0800
    • Engine revision ae90085a84
    • Dart version 2.10.4

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/nick/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.3, Build version 12C33
    • CocoaPods version 1.9.3

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 42.1.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.52.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.18.0

 
[!] Connected device                          
    ! No devices available

! Doctor found issues in 1 category.
@natebosch
Copy link
Member

Do you have a minimal reproduction case? What version of the package are you using, can you try updating?

I'm unable to see a code path where style could be null here.

@ncb000gt
Copy link
Author

ncb000gt commented Jan 5, 2021

@natebosch path is on ^1.7.0. I can try 1.8.0 but it looks like it's a pre-release. I don't have a specific reproduction case. Sometimes I don't run into this issue, most of the time I do when running flutter test.

I didn't see anything obvious either about style being null or getting cleared which was why I opened the issue. Thanks for taking a look. I'll post more if I find more. Let me know if you notice anything else. Thanks

@natebosch
Copy link
Member

I'm stumped.

The field is final.

final InternalStyle style;

The only 2 places which assign the field either have a null fallback, or assign directly to Style.platform.

if (style == null) {
style = Style.platform;

: style = Style.platform as InternalStyle,

Style.platform can only hold a few values:

path/lib/src/style.dart

Lines 33 to 45 in 10c778c

static final Style platform = _getPlatformStyle();
/// Gets the type of the host platform.
static Style _getPlatformStyle() {
// If we're running a Dart file in the browser from a `file:` URI,
// [Uri.base] will point to a file. If we're running on the standalone,
// it will point to a directory. We can use that fact to determine which
// style to use.
if (Uri.base.scheme != 'file') return Style.url;
if (!Uri.base.path.endsWith('/')) return Style.url;
if (Uri(path: 'a/b').toFilePath() == 'a\\b') return Style.windows;
return Style.posix;
}

And all of those values posix, url, and windows are non-null because they are static final fields assigned with a call to a generative constructor.

Have you made any local modifications to the package before this started happening?

@ncb000gt
Copy link
Author

ncb000gt commented Feb 9, 2021 via email

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

No branches or pull requests

2 participants