Skip to content

[Network] Network tab stops capturing HTTP requests after hot restart due to missing isolate listener #9839

@AkshatRaj00

Description

@AkshatRaj00

Bug Description

After hot restart, the Network tab stops capturing HTTP requests entirely. Requests visible before hot restart disappear and new ones are never shown. This is a P2 regression affecting all Flutter developers using DevTools Network profiling.

First reported: #9783


Root Cause (Code Analysis)

In network_controller.dart, _initHelper() calls startRecording() once on initial connection:

void _initHelper() async {
  // ...
  if (serviceConnection.serviceManager.connectedState.value.connected) {
    await startRecording(); // ← called once, never again
  }
}

startRecording() ultimately calls:

await http_service.toggleHttpRequestLogging(true); // enables on current isolates
await networkService.toggleSocketProfiling(true);   // enables on current isolates

The problem: Both calls use service.forEachIsolate(...) at the time of invocation. When a hot restart occurs, the Dart VM disposes all existing isolates and creates a new root isolate. The new isolate is never registered with toggleHttpRequestLogging(true), so HTTP profiling is disabled on it — and the Network tab never receives new requests.

network_service.dart's _refreshHttpProfile() also tracks per-isolate refresh times in lastHttpDataRefreshTimePerIsolate, but new isolates start with updatedSince: 0 — they should receive all requests — yet nothing shows up because HTTP logging is simply not enabled on the new isolate.


Expected Behavior

After hot restart, the Network tab should continue capturing HTTP requests from the newly spawned isolate.

Actual Behavior

Network tab freezes / stops capturing. No new requests appear after hot restart.


Fix

Listen to serviceConnection.serviceManager.isolateManager.onIsolateCreated in NetworkController.init() and re-enable HTTP logging + socket profiling for new isolates:

@override
void init() {
  super.init();
  _initHelper();
  addAutoDisposeListener(
    _currentNetworkRequests,
    _filterAndRefreshSearchMatches,
  );
  // Re-enable HTTP logging on new isolates (e.g. after hot restart)
  autoDisposeStreamSubscription(
    serviceConnection
        .serviceManager
        .isolateManager
        .onIsolateCreated
        .listen((_) async {
      if (_recordingNotifier.value) {
        await http_service.toggleHttpRequestLogging(true);
        await networkService.toggleSocketProfiling(true);
      }
    }),
  );
}

This ensures HTTP profiling is re-enabled every time a new isolate is spawned, covering hot restart, hot reload edge cases, and add-to-app scenarios.


Environment

Affects all DevTools versions where Network recording is present. Confirmed on DevTools 2.54.2.

Flutter 3.41.7 • channel stable
DevTools 2.54.2

PR

Fix is ready — see linked PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions