Handle Version Skew Errors from build_daemon (#2861)

Reports version skew issues in webdev when incompatible `build_daemon` versions are used.

See: https://github.com/dart-lang/build/pull/5061

Also makes build_runner versions consistent across tests/fixtures (v2.16.0).
diff --git a/debug_extension/pubspec.yaml b/debug_extension/pubspec.yaml
index 72e080c..a68e255 100644
--- a/debug_extension/pubspec.yaml
+++ b/debug_extension/pubspec.yaml
@@ -14,7 +14,7 @@
 dev_dependencies:
   args: ^2.5.0
   build: ^4.0.8
-  build_runner: ^2.15.2
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.1
   dwds: ^24.1.0
   lints: ^6.1.0
diff --git a/dwds/pubspec.yaml b/dwds/pubspec.yaml
index 25600c6..42a1b30 100644
--- a/dwds/pubspec.yaml
+++ b/dwds/pubspec.yaml
@@ -38,7 +38,7 @@
 
 dev_dependencies:
   args: ^2.7.0
-  build_daemon: ^4.0.0
+  build_daemon: ^4.1.4
   dart_flutter_team_lints: ^3.5.2
   dwds_test_common:
     path: ../dwds_test_common
diff --git a/dwds_test_common/fixtures/_experiment/pubspec.yaml b/dwds_test_common/fixtures/_experiment/pubspec.yaml
index 3ee0f7b..b106411 100644
--- a/dwds_test_common/fixtures/_experiment/pubspec.yaml
+++ b/dwds_test_common/fixtures/_experiment/pubspec.yaml
@@ -11,5 +11,6 @@
   path: ^1.8.2
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/dwds_test_common/fixtures/_test/pubspec.yaml b/dwds_test_common/fixtures/_test/pubspec.yaml
index f82c911..3e86a35 100644
--- a/dwds_test_common/fixtures/_test/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test/pubspec.yaml
@@ -11,6 +11,7 @@
   path: ^1.8.2
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.8.1
 
diff --git a/dwds_test_common/fixtures/_test_circular1/pubspec.yaml b/dwds_test_common/fixtures/_test_circular1/pubspec.yaml
index 4006d58..b81da7f 100644
--- a/dwds_test_common/fixtures/_test_circular1/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_circular1/pubspec.yaml
@@ -13,5 +13,6 @@
     path: ../_test_circular2
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/dwds_test_common/fixtures/_test_circular2/pubspec.yaml b/dwds_test_common/fixtures/_test_circular2/pubspec.yaml
index df300c1..e814478 100644
--- a/dwds_test_common/fixtures/_test_circular2/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_circular2/pubspec.yaml
@@ -11,5 +11,6 @@
     path: ../_test_circular1
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/dwds_test_common/fixtures/_test_dot_shorthands/pubspec.yaml b/dwds_test_common/fixtures/_test_dot_shorthands/pubspec.yaml
index f91980f..bbc2e8b 100644
--- a/dwds_test_common/fixtures/_test_dot_shorthands/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_dot_shorthands/pubspec.yaml
@@ -7,5 +7,6 @@
   sdk: ^3.10.0
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/dwds_test_common/fixtures/_test_hot_reload/pubspec.yaml b/dwds_test_common/fixtures/_test_hot_reload/pubspec.yaml
index 7a2c88f..6dc814a 100644
--- a/dwds_test_common/fixtures/_test_hot_reload/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_hot_reload/pubspec.yaml
@@ -5,3 +5,8 @@
 publish_to: none
 environment:
   sdk: ^3.10.0-0.0.dev
+
+dev_dependencies:
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
+  build_web_compilers: ^4.8.1
diff --git a/dwds_test_common/fixtures/_test_hot_reload_breakpoints/pubspec.yaml b/dwds_test_common/fixtures/_test_hot_reload_breakpoints/pubspec.yaml
index 4bb8adf..916f649 100644
--- a/dwds_test_common/fixtures/_test_hot_reload_breakpoints/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_hot_reload_breakpoints/pubspec.yaml
@@ -5,3 +5,8 @@
 publish_to: none
 environment:
   sdk: ^3.10.0-0.0.dev
+
+dev_dependencies:
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
+  build_web_compilers: ^4.8.1
diff --git a/dwds_test_common/fixtures/_test_hot_restart1/pubspec.yaml b/dwds_test_common/fixtures/_test_hot_restart1/pubspec.yaml
index c227c1d..9acf0a4 100644
--- a/dwds_test_common/fixtures/_test_hot_restart1/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_hot_restart1/pubspec.yaml
@@ -11,5 +11,6 @@
   path: ^1.6.1
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/dwds_test_common/fixtures/_test_hot_restart2/pubspec.yaml b/dwds_test_common/fixtures/_test_hot_restart2/pubspec.yaml
index 7110d83..1027a22 100644
--- a/dwds_test_common/fixtures/_test_hot_restart2/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_hot_restart2/pubspec.yaml
@@ -13,5 +13,6 @@
     path: ../_test_hot_restart1
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.8.1
diff --git a/dwds_test_common/fixtures/_test_hot_restart_breakpoints/pubspec.yaml b/dwds_test_common/fixtures/_test_hot_restart_breakpoints/pubspec.yaml
index b05e96d..8bbeb52 100644
--- a/dwds_test_common/fixtures/_test_hot_restart_breakpoints/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_hot_restart_breakpoints/pubspec.yaml
@@ -7,6 +7,7 @@
   sdk: ^3.10.0-0.0.dev
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.8.1
 
diff --git a/dwds_test_common/fixtures/_test_package/pubspec.yaml b/dwds_test_common/fixtures/_test_package/pubspec.yaml
index 142c65c..9725812 100644
--- a/dwds_test_common/fixtures/_test_package/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_package/pubspec.yaml
@@ -11,5 +11,6 @@
     path: ../_test
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
\ No newline at end of file
diff --git a/dwds_test_common/fixtures/_test_parts/pubspec.yaml b/dwds_test_common/fixtures/_test_parts/pubspec.yaml
index 57b9236..c3129bf 100644
--- a/dwds_test_common/fixtures/_test_parts/pubspec.yaml
+++ b/dwds_test_common/fixtures/_test_parts/pubspec.yaml
@@ -11,5 +11,6 @@
   path: ^1.6.1
 
 dev_dependencies:
-  build_runner: ^2.5.0
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/dwds_test_common/fixtures/_webdev_smoke/pubspec.yaml b/dwds_test_common/fixtures/_webdev_smoke/pubspec.yaml
index d370c93..f9bf432 100644
--- a/dwds_test_common/fixtures/_webdev_smoke/pubspec.yaml
+++ b/dwds_test_common/fixtures/_webdev_smoke/pubspec.yaml
@@ -7,5 +7,6 @@
   sdk: ^3.10.0-0.0.dev
 
 dev_dependencies:
-  build_runner: ^2.15.2
+  build_daemon: ^4.1.4
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 0854992..8e62594 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -7,5 +7,5 @@
   sdk: ^3.10.0-0.0.dev
 
 dev_dependencies:
-  build_runner: ^2.15.2
+  build_runner: ^2.16.0
   build_web_compilers: ^4.4.12
diff --git a/webdev/CHANGELOG.md b/webdev/CHANGELOG.md
index 46c3c2a..6fc01eb 100644
--- a/webdev/CHANGELOG.md
+++ b/webdev/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 4.0.1
+
+- Catch and report version skew errors when incompatible versions of `build_daemon` are used.
+
 ## 4.0.0
 
 - Add `module-format` flag for testing new DDC Library Bundle module format prior to release.
diff --git a/webdev/lib/src/command/build_command.dart b/webdev/lib/src/command/build_command.dart
index 9a8a7c6..2d51ac8 100644
--- a/webdev/lib/src/command/build_command.dart
+++ b/webdev/lib/src/command/build_command.dart
@@ -134,6 +134,9 @@
         'before starting a new instance with these options.\n\n',
       );
       return 1;
+    } on VersionSkew catch (_) {
+      logWriter(logging.Level.SEVERE, versionSkewMessage);
+      return 1;
     }
   }
 }
diff --git a/webdev/lib/src/daemon_client.dart b/webdev/lib/src/daemon_client.dart
index c0be0ea..4c32bc0 100644
--- a/webdev/lib/src/daemon_client.dart
+++ b/webdev/lib/src/daemon_client.dart
@@ -11,6 +11,14 @@
 
 import 'util.dart';
 
+const versionSkewMessage =
+    'Incompatible build_daemon version detected.\n\n'
+    'Try upgrading `build_daemon` in your project:\n\n'
+    '  dart pub upgrade build_daemon\n\n'
+    'If the issue persists, another dependency might be constraining '
+    '`build_daemon` to an older version. Try running:\n\n'
+    '  dart pub upgrade\n\n';
+
 /// Connects to the `build_runner` daemon.
 Future<BuildDaemonClient> connectClient(
   String workingDirectory,
diff --git a/webdev/lib/src/serve/dev_workflow.dart b/webdev/lib/src/serve/dev_workflow.dart
index e7212eb..17542e5 100644
--- a/webdev/lib/src/serve/dev_workflow.dart
+++ b/webdev/lib/src/serve/dev_workflow.dart
@@ -41,6 +41,8 @@
       'Please stop other WebDev instances running in this directory '
       'before starting a new instance with these options.',
     );
+  } on VersionSkew {
+    throw StateError(versionSkewMessage);
   }
 }
 
diff --git a/webdev/lib/src/version.dart b/webdev/lib/src/version.dart
index 66803ec..b42025e 100644
--- a/webdev/lib/src/version.dart
+++ b/webdev/lib/src/version.dart
@@ -1,2 +1,2 @@
 // Generated code. Do not modify.
-const packageVersion = '4.0.0';
+const packageVersion = '4.0.1';
diff --git a/webdev/pubspec.yaml b/webdev/pubspec.yaml
index 7a39d70..d0dfe8e 100644
--- a/webdev/pubspec.yaml
+++ b/webdev/pubspec.yaml
@@ -1,6 +1,6 @@
 name: webdev
 # Every time this changes you need to run `dart run build_runner build`.
-version: 4.0.0
+version: 4.0.1
 # We should not depend on a dev SDK before publishing.
 # publish_to: none
 description: >-
@@ -13,7 +13,7 @@
 dependencies:
   args: ^2.3.1
   async: ^2.9.0
-  build_daemon: ^4.0.0
+  build_daemon: ^4.1.4
   browser_launcher: ^1.1.0
   collection: ^1.15.0
   crypto: ^3.0.2
@@ -43,7 +43,7 @@
   analysis_config:
     path: ../_analysis_config
   build: ^4.0.8
-  build_runner: ^2.15.2
+  build_runner: ^2.16.0
   build_verify: ^3.0.0
   build_version: ^2.1.1
   test: ^1.21.1