flutter_libphonenumber icon indicating copy to clipboard operation
flutter_libphonenumber copied to clipboard

Error starting app on chrome

Open sguptazeil opened this issue 1 year ago • 9 comments

libphonenumber.min.js:7 Uncaught TypeError: Cannot set properties of null (setting 'exports')
    at libphonenumber.min.js:7:87
    at libphonenumber.min.js:7:330
(anonymous) @ libphonenumber.min.js:7
(anonymous) @ libphonenumber.min.js:7
flutter_libphonenumber_web.dart:73 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'PhoneNumberUtil')
    at getAllSupportedRegions (flutter_libphonenumber_web.dart:73:44)
    at getAllSupportedRegions.next (<anonymous>)
    at async_patch.dart:45:50
    at _RootZone.runUnary (zone.dart:1661:54)
    at _FutureListener.thenAwait.handleValue (future_impl.dart:147:18)
    at handleValueCallback (future_impl.dart:784:44)
    at _Future._propagateToListeners (future_impl.dart:813:13)
    at async._AsyncCallbackEntry.new.callback (future_impl.dart:448:9)
    at Object._microtaskLoop (schedule_microtask.dart:40:11)
    at _startMicrotaskLoop (schedule_microtask.dart:49:5)
    at async_patch.dart:177:15
Screenshot 2023-05-29 at 2 22 06 AM

sguptazeil avatar May 28 '23 20:05 sguptazeil

Nice catch. I can reproduce it on the latest flutter 3.10, but it works fine in 3.7. It must be an issue in flutter that changed in the meantime.

ghost avatar May 31 '23 12:05 ghost

It seems to be an error only in debug builds: https://github.com/flutter/flutter/issues/126713

ghost avatar May 31 '23 12:05 ghost

I would say let's keep this open and track that issue above for a fix to land in flutter. There are some workarounds mentioned here: https://stackoverflow.com/questions/55113108/is-it-possible-to-lazily-use-js-libs-with-dart/55192098#55192098 and in the linked issue above.

ghost avatar May 31 '23 12:05 ghost

Our web release have been blocked due to this issue, is there any update or workaround exists? Some of the workaround suggested doesn't solve the issue, in Release mode "flutter_libphonenumber" the code is pulled from CDN - https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@b7fe84af9b553f0f2db765a6e20c27fa867a971d/dist/libphonenumber.min.js

Error details -

Uncaught TypeError: Cannot set properties of null (setting 'exports') at libphonenumber.min.js:7:87 at libphonenumber.min.js:7:330

ramachandran-muthiah avatar Jul 11 '23 05:07 ramachandran-muthiah

@ramachandran-muthiah looking at the above issue, they also mention this is a related one: https://github.com/flutter/flutter/issues/126131

That says the fix has landed in flutter ~3 weeks ago. Does it still happen on the master channel now?

acoutts avatar Jul 19 '23 17:07 acoutts

TypeError: Cannot set properties of null (setting 'exports')
https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@b7fe84af9b553f0f2db765a6e20c27fa867a971d/dist/libphonenumber.min.js 7:87   <fn>
https://cdn.jsdelivr.net/gh/ruimarinho/google-libphonenumber@b7fe84af9b553f0f2db765a6e20c27fa867a971d/dist/libphonenumber.min.js 7:330  <fn>
TypeError: Cannot read properties of undefined (reading 'PhoneNumberUtil')
packages/flutter_libphonenumber_web/flutter_libphonenumber_web.dart 73:44  getAllSupportedRegions
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50   

I got this error too in the latest version. Tried on Chrome.

SFocus avatar Aug 10 '23 21:08 SFocus

TypeError: Cannot set properties of null (setting 'exports') Attempting to run flutter_libphonenumber 2.1.5 package example, and getting above error in Flutter 3.10.6. Runs on Android device, but not Chrome or Edge.

Tried the following to no avail: `Future main() async { WidgetsFlutterBinding.ensureInitialized(); setPathUrlStrategy();

context.callMethod('fixRequireJs'); await init(); ... `

jpflick-stx avatar Aug 14 '23 12:08 jpflick-stx

@ramachandran-muthiah looking at the above issue, they also mention this is a related one: flutter/flutter#126131

That says the fix has landed in flutter ~3 weeks ago. Does it still happen on the master channel now?

Fix with Flutter 3.13.0, thanks !

fabienbranchel avatar Aug 18 '23 08:08 fabienbranchel

Is it safe to close this now?

acoutts avatar Dec 07 '23 13:12 acoutts