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

Fix exthost error and warn logging #2366

Merged
merged 1 commit into from
Nov 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions ci/dev/vscode.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2445,10 +2445,10 @@ index 0000000000000000000000000000000000000000..693174ee0d21353c3a08a42fd30eaad1
+}
diff --git a/src/vs/server/node/connection.ts b/src/vs/server/node/connection.ts
new file mode 100644
index 0000000000000000000000000000000000000000..93062cadc627c61e0829c27a72894b81e6a0e039
index 0000000000000000000000000000000000000000..5c3caf4d12cbf9b7228699ec4fa40cb406aa6307
--- /dev/null
+++ b/src/vs/server/node/connection.ts
@@ -0,0 +1,171 @@
@@ -0,0 +1,189 @@
+import { field, Logger, logger } from '@coder/logger';
+import * as cp from 'child_process';
+import { VSBuffer } from 'vs/base/common/buffer';
Expand All @@ -2459,6 +2459,7 @@ index 0000000000000000000000000000000000000000..93062cadc627c61e0829c27a72894b81
+import { INativeEnvironmentService } from 'vs/platform/environment/common/environment';
+import { getNlsConfiguration } from 'vs/server/node/nls';
+import { Protocol } from 'vs/server/node/protocol';
+import { IExtHostReadyMessage } from 'vs/workbench/services/extensions/common/extensionHostProtocol';
+
+export abstract class Connection {
+ private readonly _onClose = new Emitter<void>();
Expand Down Expand Up @@ -2520,6 +2521,19 @@ index 0000000000000000000000000000000000000000..93062cadc627c61e0829c27a72894b81
+ }
+}
+
+interface DisconnectedMessage {
+ type: 'VSCODE_EXTHOST_DISCONNECTED';
+}
+
+interface ConsoleMessage {
+ type: '__$console';
+ // See bootstrap-fork.js#L135.
+ severity: 'log' | 'warn' | 'error';
+ arguments: any[];
+}
+
+type ExtHostMessage = DisconnectedMessage | ConsoleMessage | IExtHostReadyMessage;
+
+export class ExtensionHostConnection extends Connection {
+ private process?: cp.ChildProcess;
+ private readonly logger: Logger;
Expand Down Expand Up @@ -2596,11 +2610,15 @@ index 0000000000000000000000000000000000000000..93062cadc627c61e0829c27a72894b81
+ proc.stderr.setEncoding('utf8').on('data', (d) => this.logger.error(d));
+ }
+
+ proc.on('message', (event) => {
+ switch (event && event.type) {
+ proc.on('message', (event: ExtHostMessage) => {
+ switch (event.type) {
+ case '__$console':
+ const severity = (<any>this.logger)[event.severity] || 'info';
+ (<any>this.logger)[severity]('console', field('arguments', event.arguments));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad for not caching this too.

+ const fn = this.logger[event.severity === 'log' ? 'info' : event.severity];
+ if (fn) {
+ fn('console', field('arguments', event.arguments));
+ } else {
+ this.logger.error('Unexpected severity', field('event', event));
+ }
+ break;
+ case 'VSCODE_EXTHOST_DISCONNECTED':
+ this.logger.trace('Going offline');
Expand Down