mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove all manual uses of v8 serialization (#5548)
* Remove all manual uses of v8 serialization - Seems that sometimes the is a versioning mismatch within the binary format causes cluster screen the go grey Signed-off-by: Sebastian Malton <sebastian@malton.name> * handle ping Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
327978dbc8
commit
fae6bff6fb
8 files changed
+58
-50
No files matched your search
@@ -13,8 +13,8 @@ import { get, once } from "lodash";
|
||||
import { Node, NodeApi } from "../../../common/k8s-api/endpoints";
|
||||
import { KubeJsonApi } from "../../../common/k8s-api/kube-json-api";
|
||||
import logger from "../../logger";
|
||||
import { TerminalChannels } from "../../../renderer/api/terminal-api";
|
||||
import type { Kubectl } from "../../kubectl/kubectl";
|
||||
import { TerminalChannels } from "../../../common/terminal/channels";
|
||||
|
||||
export class NodeShellSession extends ShellSession {
|
||||
ShellType = "node-shell";
|
||||
|
||||
@@ -16,11 +16,9 @@ import { UserStore } from "../../common/user-store";
|
||||
import * as pty from "node-pty";
|
||||
import { appEventBus } from "../../common/app-event-bus/event-bus";
|
||||
import logger from "../logger";
|
||||
import type { TerminalMessage } from "../../renderer/api/terminal-api";
|
||||
import { TerminalChannels } from "../../renderer/api/terminal-api";
|
||||
import { deserialize, serialize } from "v8";
|
||||
import { stat } from "fs/promises";
|
||||
import { getOrInsertWith } from "../../common/utils";
|
||||
import { type TerminalMessage, TerminalChannels } from "../../common/terminal/channels";
|
||||
|
||||
export class ShellOpenError extends Error {
|
||||
constructor(message: string, options?: ErrorOptions) {
|
||||
@@ -161,7 +159,7 @@ export abstract class ShellSession {
|
||||
}
|
||||
|
||||
protected send(message: TerminalMessage): void {
|
||||
this.websocket.send(serialize(message));
|
||||
this.websocket.send(JSON.stringify(message));
|
||||
}
|
||||
|
||||
protected async getCwd(env: Record<string, string | undefined>): Promise<string> {
|
||||
@@ -232,17 +230,19 @@ export abstract class ShellSession {
|
||||
});
|
||||
|
||||
this.websocket
|
||||
.on("message", (data: string | Uint8Array): void => {
|
||||
.on("message", (rawData: unknown): void => {
|
||||
if (!this.running) {
|
||||
return void logger.debug(`[SHELL-SESSION]: received message from ${this.terminalId}, but shellProcess isn't running`);
|
||||
}
|
||||
|
||||
if (typeof data === "string") {
|
||||
return void logger.silly(`[SHELL-SESSION]: Received message from ${this.terminalId}`, { data });
|
||||
if (!(rawData instanceof Buffer)) {
|
||||
return void logger.error(`[SHELL-SESSION]: Received message non-buffer message.`, { rawData });
|
||||
}
|
||||
|
||||
const data = rawData.toString();
|
||||
|
||||
try {
|
||||
const message: TerminalMessage = deserialize(data);
|
||||
const message: TerminalMessage = JSON.parse(data);
|
||||
|
||||
switch (message.type) {
|
||||
case TerminalChannels.STDIN:
|
||||
@@ -251,6 +251,9 @@ export abstract class ShellSession {
|
||||
case TerminalChannels.RESIZE:
|
||||
shellProcess.resize(message.data.width, message.data.height);
|
||||
break;
|
||||
case TerminalChannels.PING:
|
||||
logger.silly(`[SHELL-SESSION]: ${this.terminalId} ping!`);
|
||||
break;
|
||||
default:
|
||||
logger.warn(`[SHELL-SESSION]: unknown or unhandleable message type for ${this.terminalId}`, message);
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user