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

TypeError: Promise._immediateFn is not a function. #288

Open
hisaichi5518 opened this issue Feb 18, 2020 · 1 comment
Open

TypeError: Promise._immediateFn is not a function. #288

hisaichi5518 opened this issue Feb 18, 2020 · 1 comment

Comments

@hisaichi5518
Copy link

Environment

Plugin version:

  flutter_inappwebview:
    git:
      url: git@github.com:pichillilorenzo/flutter_inappwebview.git
      ref: '9c7ac0d'

I am using 9c7ac0d to solve this issue.
#209 (comment)

iOS version:
iOS 13.1

Device information:
iPhone 11 Pro Max Simulator

 $ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Mac OS X 10.15.3 19D76, locale ja-JP)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.1)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.2)
[✓] VS Code (version 1.42.0)
[✓] Connected device (2 available)

Description

Expected behavior:

This will set a global Promise object if the browser doesn't already have window.Promise.

Current behavior:

override native Promise object.

Steps to reproduce

  1. Use 9c7ac0d
  2. Use Promise.resolve() in JavaScript.
  3. function is not found Error!

Stacktrace/Logcat

flutter: [CONSOLE.ERROR] TypeError: Promise._immediateFn is not a function. (In 'Promise._immediateFn(function() {
flutter:         if (!self._handled) {
flutter:           Promise._unhandledRejectionFn(self._value);
flutter:         }
flutter:       })', 'Promise._immediateFn' is undefined)

Reason

Overridden in the code below.
https://github.com/pichillilorenzo/flutter_inappwebview/blob/master/ios/Classes/InAppWebView.swift#L57

function Promise(fn) {
    if (!(this instanceof Promise))
      throw new TypeError("Promises must be constructed via new");
    if (typeof fn !== "function") throw new TypeError("not a function");
    this._state = 0;
    this._handled = false;
    this._value = undefined;
    this._deferreds = [];
    doResolve(fn, this);
};

Solution

Using the code at the following URL.
it will not set a global Promise object if the browser already has window.Promise.
https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js

@pichillilorenzo
What do you think about this solution?

hisaichi5518 added a commit to hisaichi5518/flutter_inappwebview that referenced this issue Feb 18, 2020
This was referenced Jul 6, 2020
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

1 participant