Description
Getting a consistent SocketException: Write failed (OS Error: Broken pipe, errno = 32) error during the build script precompilation phase when running dart run build_runner build --delete-conflicting-outputs. The error occurs before any actual code generation takes place.
This issue is blocking our development workflow as we cannot generate any required code files, and we would greatly appreciate any guidance on resolving this or a recommended workaround to proceed with development
Full Error Stack Trace
Building package executable... (3.5s)
Built build_runner:build_runner.
[INFO] Generating build script completed, took 346ms
[INFO] Precompiling build script......Unhandled exception:
SocketException: Write failed (OS Error: Broken pipe, errno = 32), port = 0
#0 _NativeSocket.write (dart:io-patch/socket_patch.dart:1475:34)
#1 _RawSocket.write (dart:io-patch/socket_patch.dart:2400:15)
#2 _Socket._write (dart:io-patch/socket_patch.dart:2936:18)
#3 _SocketStreamConsumer.write (dart:io-patch/socket_patch.dart:2659:28)
#4 _SocketStreamConsumer.addStream.<anonymous closure> (dart:io-patch/socket_patch.dart:2607:13)
#5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1778:10)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:312:7)
#8 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:798:19)
#9 _StreamController._add (dart:async/stream_controller.dart:663:7)
#10 _StreamController.add (dart:async/stream_controller.dart:618:5)
#11 _StreamSinkImpl.add (dart:io/io_sink.dart:155:17)
#12 _IOSinkImpl.write (dart:io/io_sink.dart:296:5)
#13 _Socket.write (dart:io-patch/socket_patch.dart:2765:36)
#14 _StdSink.writeln (dart:io/stdio.dart:442:13)
#15 FrontendServerClient._sendCommand (package:frontend_server_client/src/frontend_server_client.dart:328:21)
#16 FrontendServerClient.compile (package:frontend_server_client/src/frontend_server_client.dart:156:7)
#17 _createKernelIfNeeded.<anonymous closure> (package:build_runner/src/build_script_generate/bootstrap.dart:173:37)
#18 logTimedAsync (package:build_runner_core/src/logging/logging.dart:25:30)
#19 _createKernelIfNeeded (package:build_runner/src/build_script_generate/bootstrap.dart:171:11)
<asynchronous suspension>
#20 generateAndRun (package:build_runner/src/build_script_generate/bootstrap.dart:72:22)
<asynchronous suspension>
#21 main (file:///Users/xuantriet96/.pub-cache/hosted/pub.dev/build_runner-2.4.7/bin/build_runner.dart:99:24)
<asynchronous suspension>
Dependencies using code generation:
dependencies:
freezed_annotation: 2.4.1
json_annotation: 4.8.1
retrofit: ^4.0.3
dev_dependencies:
build_runner: 2.4.15
freezed: ^2.4.6
json_serializable: ^6.7.1
retrofit_generator: ^7.0.8
Environment:
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.5 24F74 darwin-arm64, locale en-VN) [469ms]
• Flutter version 3.29.3 on channel stable at /Users/xuantriet96/Documents/trietlam/framework/fvm/versions/3.29.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ea121f8859 (5 weeks ago), 2025-04-11 19:10:07 +0000
• Engine revision cf56914b32
• Dart version 3.7.2
• DevTools version 2.42.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [2.2s]
• Android SDK at /Users/xuantriet96/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [1,891ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16E140
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [14ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.3) [14ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
[✓] VS Code (version 1.98.2) [12ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.106.0
[✓] Connected device (4 available) [6.8s]
• iPhone (wireless) (mobile) • 00008110-001A68520EF9A01E • ios • iOS 18.4.1 22E252
• macOS (desktop) • macos • darwin-arm64 • macOS 15.5 24F74 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.5 24F74 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 136.0.7103.114
[✓] Network resources [1,747ms]
• All expected network resources are available.
• No issues found!
Troubleshooting Steps Already Tried
[ ] Killed all dart/flutter/build_runner processes
[ ] Cleaned project (flutter clean, removed .dart_tool/, pubspec.lock)
[ ] Cleared pub cache (dart pub cache clean)
[ ] Increased memory allocation (--old_gen_heap_size=4096)
[ ] Tried old build_runner versions
[ ] Used different command variations (dart run vs flutter packages pub run)
[ ] Checked system resources (sufficient RAM and disk space available)
[ ] Attempted building specific targets only
[ ] Created custom build.yaml configuration