Fixing `Method not found: 'promiseToFuture'.`
I tried to run a Dart Web project I hadn't touched for a while, and after updating my dependencies and running it, I got this:
[SEVERE]build_web_compilers:ddc on package:firebase/src/app.ddc.module (cached): Error compiling dartdevc module:firebase|lib/src/app.ddc.js
packages/firebase/src/utils.dart:139:19: Error: Method not found: 'promiseToFuture'.
value = await util.promiseToFuture(thenable);
^^^^^^^^^^^^^^^
TLDR
Update the Dart SDK: https://dart.dev/get-dart. Although the dev channel didn't work, stable channel worked.
Long story
Googling the error sent me straight to this issue: https://github.com/FirebaseExtended/firebase-dart/issues/251
Apparently it's already fixed in the SDK. Not sure what this means I should do. Should I update webdev? Should I update build_runner? The post mentions a commit that's from October 2019.
I checked my own version of Dart:
% dart --version
Dart VM version: 2.7.0-dev.0.0 (Tue Nov 5 12:57:33 2019 +0100) on "macos_x64"
It turns out there's a newer one available now:
% brew info dart
dart-lang/dart/dart: stable 2.7.0, devel 2.8.0-dev.0.0
After updating Dart to that devel version and running webdev again, I get a bunch of random errors. A bunch as in... 8000 lines of severe errors. And I don't understand what they mean.
So I tried to revert back to Stable:
% brew unlink dart
Unlinking /usr/local/Cellar/dart/2.8.0-dev.11.0... 9 symlinks removed
% brew install dart
==> Installing dart from dart-lang/dart
==> Downloading https://storage.googleapis.com/dart-archive/channels/stable/release/2.7.1/sdk/dartsdk-macos-x64-release.zip
######################################################################## 100.0%
% webdev serve
Can't load Kernel binary: Invalid kernel binary format version.
[INFO] Connecting to the build daemon...
And after a few minutes:
% webdev serve
Can't load Kernel binary: Invalid kernel binary format version.
[WARNING] Throwing away cached asset graph due to Dart SDK update.
[INFO] Cleaning up outputs from previous builds. completed, took 1.3s
[INFO] Building new asset graph completed, took 2.5s
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms
[INFO] Serving `web` on http://127.0.0.1:8080
[INFO] Generating SDK summary completed, took 5.1s
[INFO] Running build completed, took 1m 21s
[INFO] Caching finalized dependency graph completed, took 398ms
[INFO] Succeeded after 1m 21s with 6912 outputs (15525 actions)
[INFO] --------------------------------------------------------------------------------------------------------------------------------------------
Victory!