Repository navigation
Description
Steps to reproduce
I don't have great steps to reproduce, it's somewhat inconsistent and I can only repo on GH Actions and in a local container (with a wonky setup).
I'm running Dart-Code's E2E Playwright tests that try to verify the widget preview, and sometimes it crashes.
Logs look approximately like:
[Info] Spawning flutter with args ["widget-preview","start","--machine","--web-server",...]
[Info] <== widget_preview.initializing
[Info] "Launching analysis server..."
[warning] "Lost connection to the Dart Tooling Daemon (DTD). Live preview updates are paused.
Details: JSON-RPC error 103: Stream already subscribed"
[Info] "Launching the Widget Preview Scaffold on Web Server..."
[Info] "Launching lib/main.dart on Web Server in debug mode..."
[Info] "Triggering reload..." x3 (all in the same second)
[error] "Flutter failed to read file at /tmp/flutter_tools.XXX/web_entrypoint.dart.
PathNotFoundException ... errno 2"
[Error] Process flutter/bin/flutter terminated! 1
[Error] Widget Preview server process terminatedLooking in dtd_services my suspicion is a race condition in calls to _waitForLspService() being called twice:
- First by
getFlutterWidgetPreviews()as the preview starts loading - Next by
getFlutterWidgetPreviewsForFile()as a file is opened
_waitForLspService bails out if _lspServiceAvailable is already set. However it's set after await _dtd!.streamListen(kServiceStream);. This means if two calls to this function occur at the same time, both could call streamListen().
@bkonyi WDYT, does this sound plausible? I haven't fully debugged this yet, because I can only repro it in containers on remote machines, but I'll try to hack in some logging to verify if that's what's happening.
Expected results
No crash :)
Actual results
Process crashes.
Code sample
N/A
Screenshots or Video
N/A
Logs
Logs
[Info] Spawning flutter with args ["widget-preview","start","--machine","--web-server",...]
[Info] <== widget_preview.initializing
[Info] "Launching analysis server..."
[warning] "Lost connection to the Dart Tooling Daemon (DTD). Live preview updates are paused.
Details: JSON-RPC error 103: Stream already subscribed"
[Info] "Launching the Widget Preview Scaffold on Web Server..."
[Info] "Launching lib/main.dart on Web Server in debug mode..."
[Info] "Triggering reload..." x3 (all in the same second)
[error] "Flutter failed to read file at /tmp/flutter_tools.XXX/web_entrypoint.dart.
PathNotFoundException ... errno 2"
[Error] Process flutter/bin/flutter terminated! 1
[Error] Widget Preview server process terminatedFlutter Doctor output
Doctor output
└ [!] Flutter (Channel stable, 3.47.2, on Ubuntu 26.04 LTS 7.0.0-30-generic, locale en_US) [25ms]
• Flutter version 3.47.2 on channel stable at /home/ubuntu/flutter
! Warning: `dart` on your path resolves to /usr/lib/dart/bin/dart, which is not inside your current Flutter SDK checkout at /home/ubuntu/flutter. Consider adding /home/ubuntu/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d3b14c8769 (13 days ago), 2026-08-26 16:07:51 -0700
• Engine revision a804b26164
• Dart version 3.13.2
• DevTools version 2.60.0
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✗] Android toolchain - develop for Android devices [20ms]
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.
[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) [8ms]
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Linux toolchain - develop for Linux desktop [24ms]
✗ clang++ is required for Linux development.
It is likely available from your distribution (e.g.: apt install clang), or can be downloaded from https://releases.llvm.org/
✗ CMake is required for Linux development.
It is likely available from your distribution (e.g.: apt install cmake), or can be downloaded from https://cmake.org/download/
✗ ninja is required for Linux development.
It is likely available from your distribution (e.g.: apt install ninja-build), or can be downloaded from https://github.com/ninja-build/ninja/releases
✗ pkg-config is required for Linux development.
It is likely available from your distribution (e.g.: apt install pkg-config), or can be downloaded from https://www.freedesktop.org/wiki/Software/pkg-config/
[✓] Connected device (1 available) [25ms]
• Linux (desktop) • linux • linux-x64 • Ubuntu 26.04 LTS 7.0.0-30-generic
[✓] Network resources [208ms]
• All expected network resources are available.
! Doctor found issues in 4 categories.
Activity
DanTup commentedon Sep 8, 2026
@bkonyi oh, I also noticed:
(this was an AI summary of my log...)
I wonder if this is part of the cause (and whether it's related at all to the stream sub issue). I'll try add some more logging around this code and see if I can figure out what's going on - but it's possible it'll be obvious to you as you're more familiar with this code :-)
DanTup commentedon Sep 8, 2026
According to AI, my multiple reloads was because I was logging the widget-preview output into the project folder, and it was seeing that file being modified and generating output (which was then written to the log file, which repeated the cycle, and triggering rebuilds along the way).
I'll try moving my log file outside of the project for future testing, although it's not clear to me why that lead to a crash (unless there is some race if builds are triggered repeatedly?)
puneetkukreja98 commentedon Sep 9, 2026
@DanTup Thanks for reporting the issue, routing this to team-tool for further investigation.
Simliar issue:
#187322
[flutter_tools] Fix DTD "Stream already subscribed" error in widget p…
[flutter_tools] Fix DTD "Stream already subscribed" error in widget p…
[flutter_tools] Fix DTD "Stream already subscribed" error and wait fo…
Revert: [flutter_tools] Fix DTD "Stream already subscribed" error and…
DanTup commentedon Oct 1, 2026
@bkonyi re-opening this as the fix PR for this was reverted (#193637)
The reason for revert was failing tests, described here: #192930 (comment)
Reland "[flutter_tools] Fix DTD "Stream already subscribed" error and…
github-actions commentedon Oct 17, 2026
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.[flutter_tools] Fix DTD "Stream already subscribed" error and wait fo…
Revert: [flutter_tools] Fix DTD "Stream already subscribed" error and…
Reland "[flutter_tools] Fix DTD "Stream already subscribed" error and…