Skip to content

Launching Flutter Webapp with Localization via Debug Adapter Protocol crashes during compilation with Null check operator used on a null value #152819

Closed

Description

@sebthom

Steps to reproduce

  1. Create a simple Flutter project targeting Web and configure localization support according https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization
  2. Try to run the project in debug mode via a Flutter Debug Adapter targeting Web.

Expected results

The browser opens and displays the application

Actual results

  1. Running the project via the Flutter Debug Adapter targeting Web fails:
    The browser opens but cannot connection to the Dart process. The Debug Adapter Protocol process shows the following error:

    Launching lib\main.dart on Edge in debug mode...
    Unhandled exception:
    Null check operator used on a null value
    #0      FrontendCompiler.writeJavaScriptBundle (package:frontend_server/frontend_server.dart:778)
    <asynchronous suspension>
    #1      FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:966)
    <asynchronous suspension>
    #2      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1389)
    <asynchronous suspension>
    
    Exited (1).
  2. Running the project in the command line via flutter run -d edge or flutter run -d edge --hot --debug works as expected.

  3. Running the project via the Flutter Debug Adapter targeting Android works as expected.

Code sample

´

Code sample

Here is a sample project: localization_test.zip

Screenshots or Video

Screenshots / Video demonstration

image

Logs

Dart/Flutter Debug Adapter Log
CLIENT >> {"type":"request","seq":1,"command":"initialize","arguments":{"clientID":"lsp4e.debug","adapterID":"adapterId","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsStartDebuggingRequest":true}}SERVER >> 
SERVER >> {"seq":1,"type":"response","body":{"exceptionBreakpointFilters":[{"default":false,"filter":"All","label":"All Exceptions"},{"default":true,"filter":"Unhandled","label":"Uncaught Exceptions"}],"supportsClipboardContext":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsLogPoints":true,"supportsRestartFrame":true,"supportsRestartRequest":false,"supportsTerminateRequest":true,"supportsValueFormattingOptions":true},"command":"initialize","request_seq":1,"success":true}
CLIENT >> {"type":"request","seq":2,"command":"launch","arguments":{"cwd":"D:\\localization_test","toolArgs":["run","--target","lib\\main.dart","--device-id","edge"],"env":{},"evaluateGettersInDebugViews":true,"noDebug":false}}
SERVER >> {"seq":2,"type":"event","body":{},"event":"initialized"}
CLIENT >> {"type":"request","seq":3,"command":"configurationDone","arguments":{}}
SERVER >> {"seq":3,"type":"response","command":"configurationDone","request_seq":3,"success":true}
SERVER >> {"seq":4,"type":"response","command":"launch","request_seq":2,"success":true}
CLIENT >> {"type":"request","seq":4,"command":"threads"}
SERVER >> {"seq":5,"type":"response","body":{"threads":[]},"command":"threads","request_seq":4,"success":true}
SERVER >> {"seq":6,"type":"event","body":{"capabilities":{"supportsRestartRequest":true}},"event":"capabilities"}
SERVER >> {"seq":7,"type":"event","body":{"appId":"32ebed8f-9a81-4bc8-9fe5-8b7ab4283f31","deviceId":"edge","directory":"D:\\localization_test","supportsRestart":true,"launchMode":"run","mode":"debug"},"event":"flutter.appStart"}
SERVER >> {"seq":8,"type":"event","body":{"category":"console","output":"Launching lib\\main.dart on Edge in debug mode...\n"},"event":"output"}
CLIENT >> {"type":"request","seq":5,"command":"hotReload","arguments":{"reason":"save"}}
SERVER >> {"seq":9,"type":"event","body":{"category":"stderr","output":"Unhandled exception:\nNull check operator used on a null value\n#0      FrontendCompiler.writeJavaScriptBundle (package:frontend_server/frontend_server.dart:778)\n<asynchronous suspension>\n#1      FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:966)\n<asynchronous suspension>\n"},"event":"output"}
SERVER >> {"seq":10,"type":"event","body":{"category":"stderr","output":"#2      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1389)\n<asynchronous suspension>\n"},"event":"output"}
SERVER >> {"seq":11,"type":"response","command":"hotReload","request_seq":5,"success":true}
SERVER >> {"seq":12,"type":"event","body":{"output":"\nExited (1).\n"},"event":"output"}
SERVER >> {"seq":13,"type":"event","body":{},"event":"terminated"}
CLIENT >> {"type":"request","seq":6,"command":"terminate","arguments":{}}

Flutter Doctor output

Doctor output
> flutter doctor -v
[√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.19045.4651], locale de-DE)
    • Flutter version 3.22.3 on channel stable at D:\scoop\apps\flutter\current
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b0850beeb2 (2 weeks ago), 2024-07-16 21:43:41 -0700
    • Engine revision 235db911ba
    • Dart version 3.4.4
    • DevTools version 2.34.3
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[√] Windows Version (Installed version of Windows is version 10 or higher)

[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at D:\dev\android-sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = D:\dev\android-sdk
    • Java binary at: D:\scoop\apps\android-studio\current\jbr\bin\java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0--11185874)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • CHROME_EXECUTABLE = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.10.35027.167
    • Windows 10 SDK version 10.0.22621.0

[√] Android Studio (version 2023.3)
    • Android Studio at D:\scoop\apps\android-studio\current
    • 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 17.0.9+0--11185874)

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19045.4651]
    • Chrome (web)      • chrome  • web-javascript • unknown
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 127.0.2651.74

[√] Network resources
    • All expected network resources are available.

Activity

  1. changed the title [-]Flutter Webapp with Localization launched via Debug Adapter Protocol throws `Null check operator used on a null value`[/-] [+]Launching Flutter Webapp with Localization via Debug Adapter Protocol crashes during compilation with `Null check operator used on a null value`[/+] on Aug 3, 2024
  2. reopened this on Aug 4, 2024
  3. darshankawar commented on Aug 5, 2024

    @darshankawar
    Member

    2. Try to run the project in debug mode via a Flutter Debug Adapter targeting Web.

    @sebthom Can you provide the exact command to run ?

    Also, does it occur without using localization as well ? or only with it ?

  4. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 5, 2024
  5. sebthom commented on Aug 5, 2024

    @sebthom
    Author

    This only happens when flutter_localizations is configured.

    The Flutter Debug Adapter is launched via LSP4J with:

    D:\apps\scoop\apps\flutter\current\bin\flutter.bat debug_adapter
    

    The InitializeRequest arguments are:

    {
      "type": "request",
      "seq": 1,
      "command": "initialize",
      "arguments": {
        "clientID": "lsp4e.debug",
        "adapterID": "adapterId",
        "linesStartAt1": true,
        "columnsStartAt1": true,
        "pathFormat": "path",
        "supportsVariableType": true,
        "supportsVariablePaging": true,
        "supportsRunInTerminalRequest": true,
        "supportsStartDebuggingRequest": true
      }
    }

    The LaunchRequest arguments are:

    {
      "type": "request",
      "seq": 2,
      "command": "launch",
      "arguments": {
        "cwd": "D:\\localization_test",
        "toolArgs": [
          "run",
          "--target",
          "lib\\main.dart",
          "--device-id",
          "edge"
        ],
        "env": {},
        "evaluateGettersInDebugViews": true,
        "noDebug": false
      }
    }
  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 5, 2024
  7. sebthom commented on Aug 5, 2024

    @sebthom
    Author

    I think this may be an issue for @DanTup
    Now I am not sure if I should have better opened it in https://github.com/flutter/devtools

  8. sebthom commented on Aug 5, 2024

    @sebthom
    Author

    The null check error happens here: https://github.com/dart-lang/sdk/blob/60465149414572c8ca189d8f65fdb39795c4b97d/pkg/frontend_server/lib/frontend_server.dart#L778C22-L778C41

    _generator.lastKnownGoodResult!.component

    So via the Debug Adapter the frontend generator is not able to successfully create an IncrementalCompilerResult.

    I enabled the option sendLogsToClient in the LaunchRequest.

    The communication between DAP client and Flutter Debug Adapter looks like this:

    CLIENT >> {"type":"request","seq":1,"command":"initialize","arguments":{"clientID":"lsp4e.debug","adapterID":"adapterId","linesStartAt1":true,"columnsStartAt1":true,"pathFormat":"path","supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"supportsStartDebuggingRequest":true}}
    SERVER >> {"seq":1,"type":"response","body":{"exceptionBreakpointFilters":[{"default":false,"filter":"All","label":"All Exceptions"},{"default":true,"filter":"Unhandled","label":"Uncaught Exceptions"}],"supportsClipboardContext":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDelayedStackTraceLoading":true,"supportsEvaluateForHovers":true,"supportsLogPoints":true,"supportsRestartFrame":true,"supportsRestartRequest":false,"supportsTerminateRequest":true,"supportsValueFormattingOptions":true},"command":"initialize","request_seq":1,"success":true}
    CLIENT >> {"type":"request","seq":2,"command":"launch","arguments":{"cwd":"D:\\localization_test","toolArgs":["run","--target","lib\\main.dart","--device-id","edge"],"env":{},"evaluateGettersInDebugViews":true,"sendLogsToClient":true,"noDebug":false}}
    SERVER >> {"seq":2,"type":"event","body":{},"event":"initialized"}
    CLIENT >> {"type":"request","seq":3,"command":"configurationDone","arguments":{}}
    SERVER >> {"seq":3,"type":"response","command":"configurationDone","request_seq":3,"success":true}
    SERVER >> {"seq":4,"type":"response","command":"launch","request_seq":2,"success":true}
    CLIENT >> {"type":"request","seq":4,"command":"threads"}
    SERVER >> {"seq":5,"type":"response","body":{"threads":[]},"command":"threads","request_seq":4,"success":true}
    SERVER >> {"seq":6,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"daemon.connected\",\"params\":{\"version\":\"0.6.1\",\"pid\":54216}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":7,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.start\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"deviceId\":\"edge\",\"directory\":\"D:\\\\workspaces\\\\runtime-haxe4e\\\\localization_test\",\"supportsRestart\":true,\"launchMode\":\"run\",\"mode\":\"debug\"}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":8,"type":"event","body":{"capabilities":{"supportsRestartRequest":true}},"event":"capabilities"}
    SERVER >> {"seq":9,"type":"event","body":{"appId":"bd4ceccd-ce43-4987-9052-5318ff3c97c0","deviceId":"edge","directory":"D:\\localization_test","supportsRestart":true,"launchMode":"run","mode":"debug"},"event":"flutter.appStart"}
    SERVER >> {"seq":10,"type":"event","body":{"message":"<== [Flutter] Launching lib\\main.dart on Edge in debug mode...\n"},"event":"dart.log"}
    SERVER >> {"seq":11,"type":"event","body":{"category":"console","output":"Launching lib\\main.dart on Edge in debug mode...\n"},"event":"output"}
    SERVER >> {"seq":12,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.progress\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"id\":\"0\",\"progressId\":null,\"message\":\"Waiting for connection from debug service on Edge...\",\"finished\":false}}]\n"},"event":"dart.log"}
    CLIENT >> {"type":"request","seq":5,"command":"hotReload","arguments":{"reason":"save"}}
    SERVER >> {"seq":13,"type":"event","body":{"message":"==> [Flutter] [{\"id\":1,\"method\":\"app.restart\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"fullRestart\":false,\"pause\":true,\"reason\":\"save\",\"debounce\":true}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":14,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.progress\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"id\":\"1\",\"progressId\":\"hot.restart\",\"message\":\"Performing hot restart...\",\"finished\":false}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":15,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.progress\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"id\":\"2\",\"progressId\":null,\"message\":\"Waiting for connection from debug service on Edge...\",\"finished\":false}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":16,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.progress\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"id\":\"0\",\"progressId\":null,\"finished\":true}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":17,"type":"event","body":{"message":"<== [Flutter] [stderr] [85, 110, 104, 97, 110, 100, 108, 101, 100, 32, 101, 120, 99, 101, 112, 116, 105, 111, 110, 58, 10, 78, 117, 108, 108, 32, 99, 104, 101, 99, 107, 32, 111, 112, 101, 114, 97, 116, 111, 114, 32, 117, 115, 101, 100, 32, 111, 110, 32, 97, 32, 110, 117, 108, 108, 32, 118, 97, 108, 117, 101, 10, 35, 48, 32, 32, 32, 32, 32, 32, 70, 114, 111, 110, 116, 101, 110, 100, 67, 111, 109, 112, 105, 108, 101, 114, 46, 119, 114, 105, 116, 101, 74, 97, 118, 97, 83, 99, 114, 105, 112, 116, 66, 117, 110, 100, 108, 101, 32, 40, 112, 97, 99, 107, 97, 103, 101, 58, 102, 114, 111, 110, 116, 101, 110, 100, 95, 115, 101, 114, 118, 101, 114, 47, 102, 114, 111, 110, 116, 101, 110, 100, 95, 115, 101, 114, 118, 101, 114, 46, 100, 97, 114, 116, 58, 55, 55, 56, 41, 10, 60, 97, 115, 121, 110, 99, 104, 114, 111, 110, 111, 117, 115, 32, 115, 117, 115, 112, 101, 110, 115, 105, 111, 110, 62, 10]"},"event":"dart.log"}
    SERVER >> {"seq":18,"type":"event","body":{"category":"stderr","output":"Unhandled exception:\nNull check operator used on a null value\n#0      FrontendCompiler.writeJavaScriptBundle (package:frontend_server/frontend_server.dart:778)\n<asynchronous suspension>\n"},"event":"output"}
    SERVER >> {"seq":19,"type":"event","body":{"message":"<== [Flutter] [stderr] [35, 49, 32, 32, 32, 32, 32, 32, 70, 114, 111, 110, 116, 101, 110, 100, 67, 111, 109, 112, 105, 108, 101, 114, 46, 114, 101, 99, 111, 109, 112, 105, 108, 101, 68, 101, 108, 116, 97, 32, 40, 112, 97, 99, 107, 97, 103, 101, 58, 102, 114, 111, 110, 116, 101, 110, 100, 95, 115, 101, 114, 118, 101, 114, 47, 102, 114, 111, 110, 116, 101, 110, 100, 95, 115, 101, 114, 118, 101, 114, 46, 100, 97, 114, 116, 58, 57, 54, 54, 41, 10, 60, 97, 115, 121, 110, 99, 104, 114, 111, 110, 111, 117, 115, 32, 115, 117, 115, 112, 101, 110, 115, 105, 111, 110, 62, 10, 35, 50, 32, 32, 32, 32, 32, 32, 108, 105, 115, 116, 101, 110, 65, 110, 100, 67, 111, 109, 112, 105, 108, 101, 46, 60, 97, 110, 111, 110, 121, 109, 111, 117, 115, 32, 99, 108, 111, 115, 117, 114, 101, 62, 32, 40, 112, 97, 99, 107, 97, 103, 101, 58, 102, 114, 111, 110, 116, 101, 110, 100, 95, 115, 101, 114, 118, 101, 114, 47, 102, 114, 111, 110, 116, 101, 110, 100, 95, 115, 101, 114, 118, 101, 114, 46, 100, 97, 114, 116, 58, 49, 51, 56, 57, 41, 10, 60, 97, 115, 121, 110, 99, 104, 114, 111, 110, 111, 117, 115, 32, 115, 117, 115, 112, 101, 110, 115, 105, 111, 110, 62, 10]"},"event":"dart.log"}
    SERVER >> {"seq":20,"type":"event","body":{"category":"stderr","output":"#1      FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:966)\n<asynchronous suspension>\n#2      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1389)\n<asynchronous suspension>\n"},"event":"output"}
    SERVER >> {"seq":21,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.stop\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"error\":\"the Dart compiler exited unexpectedly.\",\"trace\":\"#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)\\n#1      DefaultResidentCompiler._compile.<anonymous closure> (package:flutter_tools/src/compile.dart:887:13)\\n#2      _rootRun (dart:async/zone.dart:1391:47)\\n#3      _CustomZone.run (dart:async/zone.dart:1301:19)\\n#4      _CustomZone.runGuarded (dart:async/zone.dart:1209:7)\\n#5      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:418:13)\\n#6      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:428:7)\\n#7      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:317:7)\\n#8      _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)\\n#9      _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)\\n#10     _StringAdapterSink.close (dart:convert/string_conversion.dart:241:11)\\n#11     _LineSplitterSink.close (dart:convert/line_splitter.dart:141:11)\\n#12     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)\\n#13     _rootRun (dart:async/zone.dart:1391:47)\\n#14     _CustomZone.run (dart:async/zone.dart:1301:19)\\n#15     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)\\n#16     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:418:13)\\n#17     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:428:7)\\n#18     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:317:7)\\n#19     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)\\n#20     _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)\\n#21     _StringAdapterSink.close (dart:convert/string_conversion.dart:241:11)\\n#22     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:295:20)\\n#23     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:78:18)\\n#24     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)\\n#25     _rootRun (dart:async/zone.dart:1391:47)\\n#26     _CustomZone.run (dart:async/zone.dart:1301:19)\\n#27     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)\\n#28     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:418:13)\\n#29     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:428:7)\\n#30     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:317:7)\\n#31     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:792:19)\\n#32     _StreamController._closeUnchecked (dart:async/stream_controller.dart:647:7)\\n#33     _StreamController.close (dart:async/stream_controller.dart:640:5)\\n#34     _Socket._onData (dart:io-patch/socket_patch.dart:2456:21)\\n#35     _rootRunUnary (dart:async/zone.dart:1415:13)\\n#36     _CustomZone.runUnary (dart:async/zone.dart:1308:19)\\n#37     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)\\n#38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365:11)\\n#39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)\\n#40     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)\\n#41     _StreamController._add (dart:async/stream_controller.dart:658:7)\\n#42     _StreamController.add (dart:async/stream_controller.dart:606:5)\\n#43     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1943:35)\\n#44     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1372:18)\\n#45     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)\\n#46     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)\\n#47     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)\\n#48     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)\\n\"}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":22,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.progress\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"id\":\"2\",\"progressId\":null,\"finished\":true}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":23,"type":"event","body":{"message":"<== [Flutter] [{\"event\":\"app.progress\",\"params\":{\"appId\":\"bd4ceccd-ce43-4987-9052-5318ff3c97c0\",\"id\":\"1\",\"progressId\":\"hot.restart\",\"finished\":true}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":24,"type":"event","body":{"message":"<== [Flutter] [{\"id\":1,\"result\":{\"code\":1,\"message\":\"Failed to recompile application.\"}}]\n"},"event":"dart.log"}
    SERVER >> {"seq":25,"type":"response","command":"hotReload","request_seq":5,"success":true}
    SERVER >> {"seq":26,"type":"event","body":{"message":"<== [Flutter] Process exited (1)"},"event":"dart.log"}
    SERVER >> {"seq":27,"type":"event","body":{"output":"\nExited (1).\n"},"event":"output"}
    SERVER >> {"seq":28,"type":"event","body":{},"event":"terminated"}
    CLIENT >> {"type":"request","seq":6,"command":"terminate","arguments":{}}

    From this log we can extract this info:

    Unhandled exception:
    Null check operator used on a null value
    #0      FrontendCompiler.writeJavaScriptBundle (package:frontend_server/frontend_server.dart:778)
    <asynchronous suspension>
    #1      FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:966)
    <asynchronous suspension>
    #2      listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1389)
    <asynchronous suspension>
    
    the Dart compiler exited unexpectedly
    #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
    #1      DefaultResidentCompiler._compile.<anonymous closure> (package:flutter_tools/src/compile.dart:887:13)
    #2      _rootRun (dart:async/zone.dart:1391:47)
    #3      _CustomZone.run (dart:async/zone.dart:1301:19)
    #4      _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
    #5      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:418:13)
    #6      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:428:7)
    #7      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:317:7)
    #8      _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
    #9      _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
    #10     _StringAdapterSink.close (dart:convert/string_conversion.dart:241:11)
    #11     _LineSplitterSink.close (dart:convert/line_splitter.dart:141:11)
    #12     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
    #13     _rootRun (dart:async/zone.dart:1391:47)
    #14     _CustomZone.run (dart:async/zone.dart:1301:19)
    #15     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
    #16     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:418:13)
    #17     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:428:7)
    #18     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:317:7)
    #19     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
    #20     _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
    #21     _StringAdapterSink.close (dart:convert/string_conversion.dart:241:11)
    #22     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:295:20)
    #23     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:78:18)
    #24     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
    #25     _rootRun (dart:async/zone.dart:1391:47)
    #26     _CustomZone.run (dart:async/zone.dart:1301:19)
    #27     _CustomZone.runGuarded (dart:async/zone.dart:1209:7)
    #28     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:418:13)
    #29     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:428:7)
    #30     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:317:7)
    #31     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:792:19)
    #32     _StreamController._closeUnchecked (dart:async/stream_controller.dart:647:7)
    #33     _StreamController.close (dart:async/stream_controller.dart:640:5)
    #34     _Socket._onData (dart:io-patch/socket_patch.dart:2456:21)
    #35     _rootRunUnary (dart:async/zone.dart:1415:13)
    #36     _CustomZone.runUnary (dart:async/zone.dart:1308:19)
    #37     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1217:7)
    #38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:365:11)
    #39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:297:7)
    #40     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:784:19)
    #41     _StreamController._add (dart:async/stream_controller.dart:658:7)
    #42     _StreamController.add (dart:async/stream_controller.dart:606:5)
    #43     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1943:35)
    #44     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1372:18)
    #45     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
    #46     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
    #47     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
    #48     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)
  9. DanTup commented on Aug 5, 2024

    @DanTup
    Contributor

    @sebthom I don't seem to be able to repro this from VS Code:

    image

    Does it happen there for you? From the error, it doesn't seem like this should be specific to running through DAP, the debug adapter is ultimately just running flutter run:

    final List<String> toolArgs = <String>[
    'run',
    '--machine',
    if (!enableFlutterDds) '--no-dds',
    if (enableDebugger) '--start-paused',
    // Structured errors are enabled by default, but since we don't connect
    // the VM Service for noDebug, we need to disable them so that error text
    // is sent to stderr. Otherwise the user will not see any exception text
    // (because nobody is listening for Flutter.Error events).
    if (!enableDebugger)
    '--dart-define=flutter.inspector.structuredErrors=false',
    ];

    The exception is coming from this code:

    https://github.com/dart-lang/sdk/blob/3.4.3/pkg/frontend_server/lib/frontend_server.dart#L778

    @sebthom one thing I notice in your log is that it looks like there might be a hot reload request before the app has finished starting up:

    CLIENT >> {"type":"request","seq":5,"command":"hotReload","arguments":{"reason":"save"}}
    

    This is in both of your logs. Does the issue occur if you don't send this, and do you know why it's being sent? (it wasn't in your steps to repro so I don't know if it was triggered deliberately or accidentally). If the issue is specific to a hot reload sent during startup, the fix might be to delay these requests until the app is started (or just drop them during startup).

  10. sebthom commented on Aug 5, 2024

    @sebthom
    Author

    @DanTup awesome, that's it. thanks a lot! When launching the app, flutter regenerates the localization_test/.dart_tool/flutter_gen/gen_l10n/app_localizations.dart which triggers a hot reload action in the client. I now changed the code to not trigger hot-reloads until the debug adapter sends the dart.debuggerUris notification. after that point it seems safe to trigger a reloads.

  11. DanTup commented on Aug 5, 2024

    @DanTup
    Contributor

    I think there should be an app.started event too (not app.start) which comes sooner, which is probably a better event to use (since the debug URIs can become available much before the app is really ready). I think I had some issues in the past when trying to use the debugger immediately after getting that event.

  12. added
    r: solvedIssue is closed as solved
    and removed
    in triagePresently being triaged by the triage team
    on Aug 7, 2024
  13. github-actions commented on Aug 21, 2024

    @github-actions

    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 -v and a minimal reproduction of the issue.

  14. locked as resolved and limited conversation to collaborators on Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: solvedIssue is closed as solved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions