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

Closed
hisaichi5518 opened this issue Feb 18, 2020 · 3 comments
Closed

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

hisaichi5518 opened this issue Feb 18, 2020 · 3 comments
Labels

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
Copy link

github-actions bot commented Oct 7, 2024

This issue is stale and has been automatically closed because it has been open for more than 365 days with no activity. Please reopen a new issue if you still have it.

@github-actions github-actions bot added the stale label Oct 7, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2024
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant