1

I updated Flutter SDK yesterday and since then my web app doesn't run. I just see a white screen and in the console/log I see this error:

Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.

Uncaught (in promise) TypeError: this._didCreateEngineInitializerResolve is not a function
    at FlutterLoader._didCreateEngineInitializer (flutter.js:61:12)
    at webOnlyWarmupEngine (initialization.dart:97:12)
    at webOnlyWarmupEngine.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:123:5)
    at Object.webOnlyWarmupEngine (initialization.dart:63:33)
    at main (web_entrypoint.dart:19:12)
    at main.next (<anonymous>)
    at runBody (async_patch.dart:84:54)
    at Object._async [as async] (async_patch.dart:123:5)
    at main$ (web_entrypoint.dart:18:18)
    at main_module.bootstrap.js:19:10
    at Array.forEach (<anonymous>)
    at window.$dartRunMain (main_module.bootstrap.js:18:32)
    at <anonymous>:1:8
    at Object.runMain (client.js:8790:21)
    at client.js:24706:19
    at _wrapJsFunctionForAsync_closure.$protected (client.js:3471:15)
    at _wrapJsFunctionForAsync_closure.call$2 (client.js:11541:12)
    at Object._asyncStartSync (client.js:3435:20)
    at main__closure4.$call$body$main__closure (client.js:24719:16)
    at main__closure4.call$1 (client.js:24645:19)
    at StaticClosure._rootRunUnary (client.js:3833:18)
    at _CustomZone.runUnary$2$2 (client.js:12941:39)
    at _CustomZone.runUnaryGuarded$1$2 (client.js:12888:14)
    at _ForwardingStreamSubscription._sendData$1 (client.js:12481:19)
    at _ForwardingStreamSubscription._add$1 (client.js:12427:15)
    at _ForwardingStreamSubscription._add$1 (client.js:12763:12)
    at _MapStream._handleData$2 (client.js:12824:12)
    at _ForwardingStreamSubscription._handleData$1 (client.js:12789:20)
    at tear_off.<anonymous> (client.js:1388:45)
    at StaticClosure._rootRunUnary (client.js:3833:18)
    at _CustomZone.runUnary$2$2 (client.js:12941:39)
    at _CustomZone.runUnaryGuarded$1$2 (client.js:12888:14)
    at _ControllerSubscription._sendData$1 (client.js:12481:19)
    at _ControllerSubscription._add$1 (client.js:12427:15)
    at _SyncStreamController._sendData$1 (client.js:12275:32)
    at _SyncStreamController.add$1 (client.js:12156:15)
    at tear_off.<anonymous> (client.js:1446:48)
    at StaticClosure._rootRunUnary (client.js:3833:18)
    at _CustomZone.runUnary$2$2 (client.js:12941:39)
    at _CustomZone.runUnaryGuarded$1$2 (client.js:12888:14)
    at _ControllerSubscription._sendData$1 (client.js:12481:19)
    at _ControllerSubscription._add$1 (client.js:12427:15)
    at _SyncStreamController._sendData$1 (client.js:12275:32)
    at _SyncStreamController.add$1 (client.js:12156:15)
    at _GuaranteeSink.add$1 (client.js:24124:25)
    at HtmlWebSocketChannel_closure1.call$1 (client.js:24430:10)
    at _EventStreamSubscription_closure.call$1 (client.js:17925:26)
    at StaticClosure._rootRunUnary (client.js:3839:16)
    at _CustomZone.runUnary$2$2 (client.js:12941:39)
    at _CustomZone.runUnaryGuarded$1$2 (client.js:12888:14)
    at _CustomZone_bindUnaryCallbackGuarded_closure.call$1 (client.js:13078:25)
    at invokeClosure (client.js:1277:26)
    at WebSocket.<anonymous> (client.js:1296:18)

It looks like the error is coming from the auto generated flutter.js file. In that file there is this method:

_didCreateEngineInitializer(engineInitializer) {
      if (typeof this._didCreateEngineInitializerResolve != "function") {
        console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead.");
      }
      this._didCreateEngineInitializerResolve(engineInitializer);
      // Remove the public method after it's done, so Flutter Web can hot restart.
      delete this.didCreateEngineInitializer;
    }

The line that causes the exceptions is this:

this._didCreateEngineInitializerResolve(engineInitializer);

I have tried cleaning and rebuilding but the files gets created with the same code and I keep getting the same error.

flutter.js is added as a script in the index.html file. Here is index.html content:

<!DOCTYPE html>
<html>
<head>

  <meta charset="UTF-8">
  <meta content="IE=Edge" http-equiv="X-UA-Compatible">
  <meta name="description" content="Space Shuttle web application.">

  <!-- iOS meta tags & icons -->
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="space_shuttle_web_application">
  <link rel="apple-touch-icon" href="icons/Icon-192.png">

  <!-- Favicon -->
  <link rel="icon" type="image/png" href="favicon.png"/>

  <title>space_shuttle_web_application</title>
  <link rel="manifest" href="manifest.json">

  <script>
    // The value below is injected by flutter build, do not touch.
    var serviceWorkerVersion = null;
  </script>
  <!-- This script adds the flutter initialization JS code -->
  <script src="flutter.js" defer></script>

  <script src="https://js.stripe.com/v3/"></script>
</head>
<body>
<script src="https://www.gstatic.com/firebasejs/9.13.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/9.13.0/firebase-firestore.js"></script>
<script>
      var firebaseConfig = {
        apiKey: "..",
        authDomain: "...",
        databaseURL: "...",
        projectId: "...",
        storageBucket: "...",
        messagingSenderId: "...",
        appId: "...",
        measurementId: "...",
      };

      // Initialize Firebase
      firebase.initializeApp(firebaseConfig);
      firebase.analytics();
    </script>
<script>
    if ('serviceWorker' in navigator) {
      window.addEventListener('load', function () {
        navigator.serviceWorker.register('flutter_service_worker.js');
      });
    }
  </script>
<script src="main.dart.js" type="application/javascript"></script>

</body>
</html>

1 Answer 1

1

If anyone is facing this issue. The problem is indeed in the index.html file. The issue wasn't the flutter upgrade. The issue I think is in this part:

<script>
    if ('serviceWorker' in navigator) {
      window.addEventListener('load', function () {
        navigator.serviceWorker.register('flutter_service_worker.js');
      });
    }
</script>

I replaced it with:

<script>
    window.addEventListener('load', function(ev) {
      // Download main.dart.js
      _flutter.loader.loadEntrypoint({
        serviceWorker: {
          serviceWorkerVersion: serviceWorkerVersion,
        }
      }).then(function(engineInitializer) {
        return engineInitializer.initializeEngine();
      }).then(function(appRunner) {
        return appRunner.runApp();
      });
    });
  </script>

And it fixed the error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.