Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textDocument/didClose Expected to link dart:core and dart:async first #3625

Closed
dcharkes opened this issue Oct 20, 2021 · 17 comments
Closed

textDocument/didClose Expected to link dart:core and dart:async first #3625

dcharkes opened this issue Oct 20, 2021 · 17 comments
Labels
awaiting info Requires more information from the customer to progress is bug stale Will be closed soon if no response.

Comments

@dcharkes
Copy link

Bad state: Expected to link dart:core and dart:async first:

from pkg/analyzer/lib/src/summary2/linked_element_factory.dart

An error occurred while handling textDocument/didClose notification

!! PLEASE REVIEW THIS LOG FOR SENSITIVE INFORMATION BEFORE SHARING !!

Dart Code extension: 3.27.2
Flutter extension: 3.27.0 (not activated)

App: Visual Studio Code
Remote: ssh-remote
Version: 1.61.1
Platform: linux

Workspace type: Dart
Analyzer type: LSP
Multi-root?: false

Dart SDK:
    Loc: /usr/local/google/home/dacoharkes/dart-sdk/sdk/out/ReleaseX64/dart-sdk
    Ver: 2.15.0-edge.1572894a8558ad3d3d85c08b9eb6843a940614de
Flutter SDK:
    Loc: /usr/local/google/home/dacoharkes/flt/flutter
    Ver: 2.6.0-12.0.pre.173

HTTP_PROXY: undefined
NO_PROXY: undefined

Logging Categories:
    General, Analyzer, CommandProcesses

Wed Oct 20 2021 [08:07:27 GMT+0000 (Coordinated Universal Time)] Log file started
[8:07:28 AM] [Analyzer] [Info] ==> Content-Length: 239
[8:07:28 AM] [Analyzer] [Info] ==> {"jsonrpc":"2.0","id":445,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/vm/lib/transformations/ffi/definitions.dart"},"position":{"line":1498,"character":62}}}
[8:07:28 AM] [Analyzer] [Info] <== Content-Length: 422
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id":445,"jsonrpc":"2.0","result":[{"originSelectionRange":{"start":{"line":1498,"character":61},"end":{"line":1498,"character":64}},"targetUri":"file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/out/ReleaseX64/dart-sdk/lib/core/int.dart","targetRange":{"start":{"line":22,"character":0},"end":{"line":336,"character":1}},"targetSelectionRange":{"start":{"line":22,"character":15},"end":{"line":22,"character":18}}}]}
[8:07:28 AM] [Analyzer] [Info] ==> Content-Length: 13317
[8:07:28 AM] [Analyzer] [Info] ==> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/out/ReleaseX64/dart-sdk/lib/core/int.dart","languageId":"dart","version":1,"text":"// Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file\n// for details. All rights reserved. Use of this source code is governed by a\n// BSD-style license that can be found in the LICENSE file.\n\npart of dart.core;\n\n/// An integer number.\n///\n/// The default implementation of `int` is 64-bit two's complement integers\n/// with operations that wrap to that range on overflow.\n///\n/// **Note:** When compiling to JavaScript, integers are restricted to values\n/// that can be represented exactly by double-precision floating point values.\n/// The available integer values include all integers between -2^53 and 2^53,\n/// and some integers with larger magnitude. That includes some integers larger\n/// than 2^63.\n/// The behavior of the operators and methods in the [int]\n/// class therefore sometimes differs between the Dart VM and Dart code\n/// compiled to JavaScript. For example, the bitwise operators truncate their\n/// operands to 32-bit integers when compiled to JavaScript.\n///\n/// Classes cannot extend, implement, or mix in `int`.\nabstract class int extends num {\n  /// Returns the integer value of the given environment declaration [name].\n  ///\n  /// The result is the same as would be returned by:\n  /// ```dart template:expression\n  /// int.tryParse(const String.fromEnvironment(name, defaultValue: \"\"))\n  ///     ?? defaultValue\n  /// ```\n  /// Example:\n  /// ```dart\n  /// const int.fromEnvironment(\"defaultPort\", defaultValue: 80)\n  /// ```\n  ///\n  /// The string value, or lack of a value, associated with a [name]\n  /// must be consistent across all calls to [String.fromEnvironment],\n  /// `int.fromEnvironment`, [bool.fromEnvironment] and [bool.hasEnvironment]\n  /// in a single program.\n  ///\…
[8:07:28 AM] [Analyzer] [Info] ==> Content-Length: 182
[8:07:28 AM] [Analyzer] [Info] ==> {"jsonrpc":"2.0","method":"textDocument/didClose","params":{"textDocument":{"uri":"file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/out/ReleaseX64/dart-sdk/lib/core/int.dart"}}}
[8:07:29 AM] [Analyzer] [Info] <== Content-Length: 146
Content-Type: application/vscode-jsonrpc; charset=utf-8
[8:07:29 AM] [Analyzer] [Info] <== {"method":"window/showMessage","params":{"type":1,"message":"An error occurred while handling textDocument/didOpen notification"},"jsonrpc":"2.0"}
[8:07:29 AM] [Analyzer] [Info] <== Content-Length: 19568
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"method":"window/logMessage","params":{"type":1,"message":"An error occurred while handling textDocument/didOpen notification: Bad state: Expected to link dart:core and dart:async first: [file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/base/nnbd_mode.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/api_prototype/experimental_flags.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/api_prototype/file_system.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/api_unstable/util.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/api_prototype/terminal_color_support.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/ticker.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/denylisted_classes.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/api_prototype/compiler_options.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/api_prototype/standard_file_system.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/base/processed_options.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/compute_platform_binaries_location.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/command_line_reporting.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/compiler_context.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/crash.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/fasta_codes.dart, file:///usr/local/google/home/dacoharkes/dart-sdk/sdk/pkg/front_end/lib/src/fasta/kernel/type_labeler.dart, file:///usr/lo…
Wed Oct 20 2021 [08:07:31 GMT+0000 (Coordinated Universal Time)] Log file ended

@DanTup I've seen this happen a couple of times. I'm building that SDK and reloading it when DartCode detects the SDK has been updated, in cases that's relevant. (I'm adding new APIs to dart:* libraries.)

Is this an error in how DartCode invokes the summaries? Or is it an error in the SDK?

@DanTup
Copy link
Member

DanTup commented Oct 26, 2021

@dcharkes does it only occur immediately after you reload the SDK, or does it persist if you restart VS Code? In theory there shouldn't be much difference, but I wonder if the error could be generated by the old server (being down down) after your compile (in which case it might just be that the compile is causing things to get into a bad state?).

The code throwing the error is here - I'm not very familiar with it (although I think it's not a Dart-Code bug). @scheglov might be better to ask.

https://github.com/dart-lang/sdk/blob/00c377c7530968cec8185b3563d41a480e552231/pkg/analyzer/lib/src/summary2/linked_element_factory.dart#L209

@DanTup DanTup added the awaiting info Requires more information from the customer to progress label Oct 26, 2021
@github-actions
Copy link

This issue has been marked stale because it is tagged awaiting-info for 20 days with no activity. Remove the stale label or comment to prevent the issue being closed in 10 days.

@DanTup
Copy link
Member

DanTup commented Jan 4, 2022

This came up again, I've filed dart-lang/sdk#48051 since it seems like something is wrong in the server (though I'm not yet sure what).

@jpSimkins
Copy link

I get about 20-30 of these messages a day. Restart seems to help for about ~5mins but then I see these again. I just ignore them as they don't seem to affect anything noticeable and my code is still being saved and working.

@DanTup
Copy link
Member

DanTup commented May 30, 2022

@jpSimkins if you have any steps to reproduce this, please post on dart-lang/sdk#48051. It'd be good to track down exactly what's happening.

I posted an idea in that thread to reduce the occurrences of it in some situations, but it doesn't resolve the underlying problem.

@dobeerman
Copy link

After two month of using I started to experience the same issue. I do not know how to reproduce it, but I'll try it later ;)

@jpSimkins
Copy link

Sorry, I upgraded to Ubuntu 22 and I had not had this issue since upgrading. Not sure if that's a factor here but I no longer see these anymore.

@hey-nicolasklein
Copy link

I'm experiencing the same issue. Mostly when opening files of the flutter sdk instead of my own.

@innomatica
Copy link

In my case, it usually happens when I select a block of code and hit the Ctrl-C key. Once it happens it shows two identical errors.

@nicolasmol
Copy link

The same here, occasionally
image

@DanTup
Copy link
Member

DanTup commented Sep 1, 2022

I made a change recently (dart-lang/sdk@0add39a) that I think should reduce the chance of this happening (it doesn't resolve the problem, but it avoids calling the code that fails in some cases where it was unnecessary - which I suspect account for the huge majority of cases).

It didn't make the branch for the recent stable releases (Flutter 3.3 / Dart 2.18), but should be included in the next (non-hotfix) releases.

@ragokan
Copy link

ragokan commented Sep 12, 2022

image
I just started trying something, and I get the errors even in an empty project.

@DanTup
Copy link
Member

DanTup commented Sep 13, 2022

@ragokan the fix noted above is only in Flutter 3.3 / Dart 2.18. It looks like you're still using Dart from Flutter 3.0.5. I think if you upgrade Flutter the issue may go away (or at least, be significantly reduced in frequency). If not, please let me know.

@DanTup
Copy link
Member

DanTup commented Sep 13, 2022

@ragokan scratch that, I misread my own comment. Unfortunately the fix did not make Flutter 3.3 (but should be in a future SDK release).

Out of interest, can you reproduce the issue reliably (eg. after restarting VS Code)?

@rrousselGit
Copy link

@DanTup I can reliably reproduce this issue while using package:custom_lint

Cloning the repository of Riverpod (https://github.com/rrousselGit/river_pod), running pub get on all sub-projects, then restarting is enough to trigger the error.
The error appears when opening/closing any file (not limited to dart files)

The issue being packages/riverpod_lint. Removing it fixes the problem.
At the root of all this is likely a bug on my side (I assume a bug on custom_lint). But vscode probably shouldn't behave this way

@DanTup
Copy link
Member

DanTup commented Dec 1, 2022

@rrousselGit I can repro this, taking a look - thanks!

@DanTup
Copy link
Member

DanTup commented Dec 1, 2022

@rrousselGit actually, I just noticed this error is slightly different when I enabled logging (it's not "Expected to link dart:core and dart:async first"):

1669889723876:Ex:An error occurred while handling textDocument/didClose notification
Invalid argument:: is a regular instance:: Instance of '_HashMap<dynamic, dynamic>'
#0      _SendPort._sendInternal (dart::isolate-patch/isolate_patch.dart::249::43)
#1      _SendPort.send (dart::isolate-patch/isolate_patch.dart::230::5)
#2      ServerIsolateChannel.sendRequest (package::analyzer_plugin/src/channel/isolate_channel.dart::249::16)
#3      PluginSession.sendRequest (package::analysis_server/src/plugin/plugin_manager.dart::948::13)
#4      PluginInfo.sendRequest (package::analysis_server/src/plugin/plugin_manager.dart::208::21)
#5      PluginManager.setAnalysisUpdateContentParams (package::analysis_server/src/plugin/plugin_manager.dart::586::14)
#6      LspAnalysisServer._notifyPluginsOverlayChanged (package::analysis_server/src/lsp/lsp_analysis_server.dart::868::21)
#7      LspAnalysisServer._afterOverlayChanged (package::analysis_server/src/lsp/lsp_analysis_server.dart::805::5)
#8      LspAnalysisServer.onOverlayDestroyed (package::analysis_server/src/lsp/lsp_analysis_server.dart::540::5)
#9      TextDocumentCloseHandler.handle.<anonymous closure> (package::analysis_server/src/lsp/handlers/handler_text_document_changes.dart::74::14)
<asynchronous suspension>
#10     LspAnalysisServer._handleNotificationMessage (package::analysis_server/src/lsp/lsp_analysis_server.dart::843::20)
<asynchronous suspension>
#11     LspAnalysisServer.handleMessage.<anonymous closure>.<anonymous closure> (package::analysis_server/src/lsp/lsp_analysis_server.dart::392::15)
<asynchronous suspension>
#12     OperationPerformanceImpl.runAsync (package::analyzer/src/util/performance/operation_performance.dart::164::18)
<asynchronous suspension>
#13     LspAnalysisServer.handleMessage.<anonymous closure> (package::analysis_server/src/lsp/lsp_analysis_server.dart::374::11)
<asynchronous suspension>

:null

I've filed #4295 about this and am taking a look now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting info Requires more information from the customer to progress is bug stale Will be closed soon if no response.
Projects
None yet
Development

No branches or pull requests

9 participants