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

"Cannot read property 'adapter' of undefined" #69147

Closed
DanTup opened this issue Feb 21, 2019 · 19 comments · Fixed by #70869
Closed

"Cannot read property 'adapter' of undefined" #69147

DanTup opened this issue Feb 21, 2019 · 19 comments · Fixed by #70869
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-code-actions Editor inplace actions (Ctrl + .) outline Source outline view issues verified Verification succeeded
Milestone

Comments

@DanTup
Copy link
Contributor

DanTup commented Feb 21, 2019

I saw this previously in #66322 in provideCodeActions which was fixed, but I've just seen the same thing on stable in provideDocumentSymbols:

ERR Cannot read property 'adapter' of undefined: TypeError: Cannot read property 'adapter' of undefined
	at e._withAdapter (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:553:140)
	at e.$provideDocumentSymbols (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:554:184)
	at t._doInvokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:644:118)
	at t._invokeHandler (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:643:744)
	at t._receiveRequest (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:642:256)
	at t._receiveOneMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:641:155)
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:638:960
	at /Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:38:994
	at e.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:44:113)
	at a (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:170:213)
	at Socket.f._socketDataListener (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:170:434)
	at Socket.emit (events.js:182:13)
	at addChunk (_stream_readable.js:279:12)
	at readableAddChunk (_stream_readable.js:264:11)
	at Socket.Readable.push (_stream_readable.js:219:10)
	at Pipe.onread (net.js:636:20)

I guess it should have the same fix (and based on the comments in that issue, Hovers may also need it?).

I was more aware of what I was doing to repro it this time... The Dart extension has code to restart itself when certain config changes (for example, the path to the Dart SDK). We run through all of the providers we created and dispose them, and then re-create them using the new SDK server client.

Based on @jrieken's comment at #66322 (comment) I guess that if this happens while there are outstanding requests, this error could occur.

@vscodebot
Copy link

vscodebot bot commented Feb 21, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@weinand weinand assigned mjbvz and unassigned weinand Feb 21, 2019
@jrieken jrieken added this to the February 2019 milestone Feb 25, 2019
@jrieken jrieken added info-needed Issue requires more information from poster outline Source outline view issues labels Feb 25, 2019
@jrieken
Copy link
Member

jrieken commented Feb 25, 2019

@DanTup does this reproduce with insiders? Since two weeks that should handle missing adapter more graceful

@DanTup
Copy link
Contributor Author

DanTup commented Feb 25, 2019

With Insiders I see this instead:

ERR no adapter found: Error: no adapter found
	at $._withAdapter (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:575:316)
	at $provideCodeActions (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:580:395)
	at h._doInvokeHandler (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:593:118)
	at h._invokeHandler (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:592:777)
	at h._receiveRequest (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:591:383)
	at h._receiveOneMessage (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:590:279)
	at define.constructor._protocol.onMessage.e (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:588:565)
	at u.fire (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43:254)
	at e (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:39:64)
	at u.fire (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:43:254)
	at s (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:168:754)
	at Socket.define.constructor._socketDataListener.e (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:168:960)
	at Socket.emit (events.js:182:13)
	at addChunk (_stream_readable.js:279:12)
	at readableAddChunk (_stream_readable.js:264:11)
	at Socket.Readable.push (_stream_readable.js:219:10)
	at Pipe.onread (net.js:636:20)

Is that expected?

@jrieken
Copy link
Member

jrieken commented Feb 26, 2019

Better. What are your steps to reproduce this?

@DanTup
Copy link
Contributor Author

DanTup commented Feb 26, 2019

When you switch SDK in the Dart extension, we dispose all of the providers and re-create them. We do it by enumerating through them calling dispose, then just re-calling the activate method for the extension:

context.subscriptions.push(vs.commands.registerCommand("_dart.reloadExtension", (_) => {
	log("Performing silent extension reload...");
	deactivate(true);
	const toDispose = context.subscriptions.slice();
	context.subscriptions.length = 0;
	for (const sub of toDispose) {
		try {
			sub.dispose();
		} catch (e) {
			logError(e);
		}
	}
	activate(context, true);
	log("Done!");
}));

@jrieken jrieken added the editor-code-actions Editor inplace actions (Ctrl + .) label Feb 26, 2019
@jrieken
Copy link
Member

jrieken commented Feb 26, 2019

So, from looking at both stack traces this happens with code actions and document symbols

@jrieken
Copy link
Member

jrieken commented Feb 26, 2019

Adding @mjbvz for code actions. @DanTup I have pushed a change that should make this better for document symbols. Tho, it's a blind fix 🙈

@jrieken jrieken removed their assignment Feb 26, 2019
@jrieken jrieken removed the info-needed Issue requires more information from poster label Feb 26, 2019
@jrieken jrieken removed this from the February 2019 milestone Feb 26, 2019
@jrieken jrieken added the bug Issue identified by VS Code Team member as probable bug label Feb 26, 2019
@DanTup
Copy link
Contributor Author

DanTup commented Feb 26, 2019

Oh yeah, I didn't even spot the stacks were different. I'll do some testing tomorrow when the next Insiders build is available. Thanks!

@mjbvz mjbvz added this to the March 2019 milestone Feb 26, 2019
@DanTup
Copy link
Contributor Author

DanTup commented Feb 27, 2019

The "no adapter found" message from Code Actions is the only error I seem to be able to repro today in Insiders. I'll do some more testing once that's fixed to see if I can find any more. Thanks!

@jrieken jrieken self-assigned this Mar 1, 2019
@jrieken
Copy link
Member

jrieken commented Mar 1, 2019

I will revert my change because of a regression it introduced

jrieken added a commit that referenced this issue Mar 1, 2019
@jrieken
Copy link
Member

jrieken commented Mar 5, 2019

I have pushed another change for document symbols

@DanTup
Copy link
Contributor Author

DanTup commented Mar 6, 2019

Document symbols still looks good to me in latest Insiders - with Outline + Breadcrumb visible and constantly switching SDK, the only one printing errors is CodeActions.

@mjbvz
Copy link
Contributor

mjbvz commented Mar 15, 2019

Repo in main VS Code codebase:

  1. Running and building VS Code from master
  2. In the file extensions/typescript-language-features/src/features/quickFix.ts, apply the following patch
diff --git a/extensions/typescript-language-features/src/features/quickFix.ts b/extensions/typescript-language-features/src/features/quickFix.ts
index 91c3f3b326..7ac5e5dc79 100644
--- a/extensions/typescript-language-features/src/features/quickFix.ts
+++ b/extensions/typescript-language-features/src/features/quickFix.ts
@@ -326,8 +326,17 @@ export function register(
 	diagnosticsManager: DiagnosticsManager,
 	telemetryReporter: TelemetryReporter
 ) {
-	return new VersionDependentRegistration(client, API.v213, () =>
-		vscode.languages.registerCodeActionsProvider(selector,
-			new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, telemetryReporter),
-			TypeScriptQuickFixProvider.metadata));
+	let sub: undefined | vscode.Disposable = undefined;
+
+	setInterval(() => {
+		if (sub) {
+			sub.dispose();
+		}
+		sub = new VersionDependentRegistration(client, API.v213, () => {
+			return vscode.languages.registerCodeActionsProvider(selector,
+				new TypeScriptQuickFixProvider(client, fileConfigurationManager, commandManager, diagnosticsManager, telemetryReporter),
+				TypeScriptQuickFixProvider.metadata);
+		});
+	}, 10);
+
 }

Bug
See errors every few seconds in developer console

@mjbvz
Copy link
Contributor

mjbvz commented Mar 16, 2019

@jrieken I can't seem to fix this error fully for the example above that re-registers a provider every 10 milliseconds. The same pattern also still breaks document symbol providers. Is this worth worrying about?

@jrieken
Copy link
Member

jrieken commented Mar 18, 2019

Is this worth worrying about?

I'd ignore it, since everything is async between two processes it's the way it is. We should maybe be more graceful when a provider isn't around, like resolving with undefined which I believe is an accepted return value for all providers. Or handle (read swallow) those errors

@mjbvz
Copy link
Contributor

mjbvz commented Mar 18, 2019

@DanTup Can you please test the latest insiders build to see if you can still hit these errors in more normal scenarios

@DanTup
Copy link
Contributor Author

DanTup commented Mar 19, 2019

Unfortunately on the very first SDK switch I got this error for both Code Actions and Document Symbols.

However, there are also other errors I got, I don't know if they're related.

Screenshot 2019-03-19 at 8 46 52 am

Screenshot 2019-03-19 at 8 47 04 am

@DanTup
Copy link
Contributor Author

DanTup commented Mar 19, 2019

I was using this Insiders from today:

1d191e8

2019-03-19T06:07:09.890Z

mjbvz added a commit to mjbvz/vscode that referenced this issue Mar 21, 2019
Fixes microsoft#69147

Due to the asynchronous communication between the exthost and main process, there may be cases where we request data from a provider that has been unregistered. This currently logs an error.

This change adds a fallback value that we can return instead when the adapter is missing.
@DanTup
Copy link
Contributor Author

DanTup commented Mar 25, 2019

Thanks, not seeing any errors switching Dart SDKs in insiders now 👍

@roblourens roblourens added the verified Verification succeeded label Mar 28, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators May 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-code-actions Editor inplace actions (Ctrl + .) outline Source outline view issues verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants