Repository navigation
Closed
Labels
r: solvedIssue is closed as solvedIssue is closed as solved
Description
Steps to reproduce
- Create a simple Flutter project targeting Web and configure localization support according https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization
- 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
-
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).
-
Running the project in the command line via
flutter run -d edgeorflutter run -d edge --hot --debugworks as expected. -
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
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.Metadata
Metadata
Assignees
Labels
r: solvedIssue is closed as solvedIssue is closed as solved

Activity
[-]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`[/+]darshankawar commentedon Aug 5, 2024
@sebthom Can you provide the exact command to run ?
Also, does it occur without using localization as well ? or only with it ?
sebthom commentedon Aug 5, 2024
This only happens when flutter_localizations is configured.
The Flutter Debug Adapter is launched via LSP4J with:
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 } }sebthom commentedon Aug 5, 2024
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
sebthom commentedon Aug 5, 2024
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!.componentSo via the Debug Adapter the frontend generator is not able to successfully create an
IncrementalCompilerResult.I enabled the option
sendLogsToClientin the LaunchRequest.The communication between DAP client and Flutter Debug Adapter looks like this:
From this log we can extract this info:
DanTup commentedon Aug 5, 2024
@sebthom I don't seem to be able to repro this from VS Code:
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:flutter/packages/flutter_tools/lib/src/debug_adapters/flutter_adapter.dart
Lines 247 to 259 in a3bbb24
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:
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).
sebthom commentedon Aug 5, 2024
@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.dartwhich triggers a hot reload action in the client. I now changed the code to not trigger hot-reloads until the debug adapter sends thedart.debuggerUrisnotification. after that point it seems safe to trigger a reloads.DanTup commentedon Aug 5, 2024
I think there should be an
app.startedevent too (notapp.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.github-actions commentedon Aug 21, 2024
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.