From b00f759f161c87bbad3d12d47fc1908fdd323b7e Mon Sep 17 00:00:00 2001 From: KingKDot Date: Mon, 4 May 2026 19:56:36 -0500 Subject: [PATCH] test --- Overlord-Client/cmd/agent/handlers/command.go | 19 ++++++++++++------- Overlord-Client/cmd/agent/plugins/manager.go | 13 +++++++++---- .../src/server/runtime-constants.ts | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Overlord-Client/cmd/agent/handlers/command.go b/Overlord-Client/cmd/agent/handlers/command.go index 9e70dbe..fa74eb6 100644 --- a/Overlord-Client/cmd/agent/handlers/command.go +++ b/Overlord-Client/cmd/agent/handlers/command.go @@ -569,12 +569,16 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in if err != nil { return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: false, Message: err.Error()}) } - if err := env.Plugins.Load(ctx, manifest, binaryBytes); err != nil { - _ = wire.WriteMsg(ctx, env.Conn, wire.PluginEvent{Type: "plugin_event", PluginID: manifest.ID, Event: "error", Error: err.Error()}) - return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: false, Message: err.Error()}) - } - _ = wire.WriteMsg(ctx, env.Conn, wire.PluginEvent{Type: "plugin_event", PluginID: manifest.ID, Event: "loaded"}) - return wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: true}) + go func() { + if err := env.Plugins.Load(ctx, manifest, binaryBytes); err != nil { + _ = wire.WriteMsg(ctx, env.Conn, wire.PluginEvent{Type: "plugin_event", PluginID: manifest.ID, Event: "error", Error: err.Error()}) + _ = wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: false, Message: err.Error()}) + return + } + _ = wire.WriteMsg(ctx, env.Conn, wire.PluginEvent{Type: "plugin_event", PluginID: manifest.ID, Event: "loaded"}) + _ = wire.WriteMsg(ctx, env.Conn, wire.CommandResult{Type: "command_result", CommandID: cmdID, OK: true}) + }() + return nil case "plugin_load_http": payload, _ := envelope["payload"].(map[string]interface{}) if payload == nil { @@ -587,7 +591,8 @@ func HandleCommand(ctx context.Context, env *runtime.Env, envelope map[string]in } pullURL, _ := payload["url"].(string) expectedSize := int64(toInt(payload["size"])) - return HandlePluginLoadHTTP(ctx, env, cmdID, manifest, pullURL, expectedSize) + go HandlePluginLoadHTTP(ctx, env, cmdID, manifest, pullURL, expectedSize) + return nil case "plugin_unload": payload, _ := envelope["payload"].(map[string]interface{}) if payload == nil || env.Plugins == nil { diff --git a/Overlord-Client/cmd/agent/plugins/manager.go b/Overlord-Client/cmd/agent/plugins/manager.go index 1acd572..0744c0d 100644 --- a/Overlord-Client/cmd/agent/plugins/manager.go +++ b/Overlord-Client/cmd/agent/plugins/manager.go @@ -6,6 +6,7 @@ import ( "errors" "log" "sync" + "time" "overlord-client/cmd/agent/wire" ) @@ -69,15 +70,19 @@ func (m *Manager) Load(ctx context.Context, manifest PluginManifest, binary []by payloadVal = string(payload) } } - err := wire.WriteMsg(context.Background(), m.writer, wire.PluginEvent{ + msg := wire.PluginEvent{ Type: "plugin_event", PluginID: pluginID, Event: event, Payload: payloadVal, - }) - if err != nil { - log.Printf("[plugin] %s send event error: %v", pluginID, err) } + go func() { + sendCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + if err := wire.WriteMsg(sendCtx, m.writer, msg); err != nil { + log.Printf("[plugin] %s send event error: %v", pluginID, err) + } + }() } hostJSON, err := json.Marshal(m.host) diff --git a/Overlord-Server/src/server/runtime-constants.ts b/Overlord-Server/src/server/runtime-constants.ts index e9d46a5..b36c5e4 100644 --- a/Overlord-Server/src/server/runtime-constants.ts +++ b/Overlord-Server/src/server/runtime-constants.ts @@ -7,5 +7,5 @@ export const MAX_WS_MESSAGE_BYTES_VIEWER = Number( process.env.MAX_WS_MESSAGE_BYTES_VIEWER || 1_000_000, ); export const MAX_WS_MESSAGE_BYTES_CLIENT = Number( - process.env.MAX_WS_MESSAGE_BYTES_CLIENT || 16_000_000, + process.env.MAX_WS_MESSAGE_BYTES_CLIENT || 64_000_000, );