dwyl / app

Clear your mind. Organise your life. Ignore distractions. Focus on what matters.
http://dwyl.github.io/app/
143 stars 22 forks source link

ReferenceError: IN_PROCESSING_REQUESTS is not defined #333

Closed milan-ciganovic closed 1 year ago

milan-ciganovic commented 1 year ago

Hi,

I've followed the guide per Speeding Up Flutter Web Load Time 🏎️ Everything works fine locally, but when deployed I get this error and fails to load main.dart.js:

Screenshot 2023-05-05 at 14 05 45

I've copied all the files from build_tools folder, added also.

RUN chmod +x ./build_tools/patch_web.sh
RUN ./build_tools/patch_web.sh --ignore-whitespace

And added to index.html:

<picture id="splash">
    <source srcset="splash/img/light-1x.png 1x, splash/img/light-2x.png 2x, splash/img/light-3x.png 3x, splash/img/light-4x.png 4x"
            media="(prefers-color-scheme: light)">
    <source srcset="splash/img/dark-1x.png 1x, splash/img/dark-2x.png 2x, splash/img/dark-3x.png 3x, splash/img/dark-4x.png 4x"
            media="(prefers-color-scheme: dark)">
    <img class="center" aria-hidden="true" src="splash/img/light-1x.png" alt="">
</picture>
<script>
    window.addEventListener('load', function(ev) {
      // Download main.dart.js
      loadScript('flutter.js').then(() => {
        // Download main.dart.js
        _flutter.loader.loadEntrypoint({
          serviceWorker: {
            serviceWorkerVersion: serviceWorkerVersion,
          },
          onEntrypointLoaded: async function(app) {
            let appRunner = await app.initializeEngine();
            await appRunner.runApp();
            // Remove loading screen when App available:
            document.querySelector('#splash').remove();
          }
        });
      })
    });

       function loadScript(src) {
      return new Promise(function (resolve, reject) {
        var script = document.createElement('script');
        script.src = src;
        script.onload = function () { resolve(); };
        script.onerror = function () { reject(); };
        document.body.appendChild(script);
        // console.log('loaded ', src)
      });
    }

</script>
milan-ciganovic commented 1 year ago

I've removed from the Dockerfile build:

RUN chmod +x ./build_tools/patch_web.sh
RUN ./build_tools/patch_web.sh --ignore-whitespace

And after the build it works, and it's also way faster... But I'm not sure what is the difference?

nelsonic commented 1 year ago

@milan-ciganovic is what you're building Open Source so we can read the code to help understand the issue? 💭

milan-ciganovic commented 1 year ago

@nelsonic It's not open source, unfortunately, I didn't do this part diff -u old.js new.js > file.js.patch Do I need to do it in the build process as well? I'm using all the files as mentioned in the build_tools example project.

nelsonic commented 1 year ago

Ok. without a bit more insightful view of the project it's like trying to diagnose in the dark. Yes, please follow the instructions that @LuchoTurtle put together step-by-step. If you are still stuck we definitely want to know so that we can improve/update the instructions. Thanks.

LuchoTurtle commented 1 year ago

@milan-ciganovic please check https://github.com/dwyl/app/pull/335

I believe there was a line missing from the .patch file which would initialize the variable that you're having trouble with IN_PROCESSING_REQUESTS.

If it works, give us a heads up :)

milan-ciganovic commented 1 year ago

Works great :) Got 76 performance from Lighthouse. Thanks guys!

LuchoTurtle commented 1 year ago

Awesome! Closing :)