Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
- Fix for potential crash during chat/tell operation. - Panic handling to prevent crashes in general. - Fix for local queue handling bug during builds that could cause queue to get stuck and cause subsequent operations to hang.
Dane Schneider85d9f3486bd8
diff --git a/app/server/db/queue.go b/app/server/db/queue.goindex 50da7738..1eb484e3 100644--- a/app/server/db/queue.go+++ b/app/server/db/queue.go@@ -152,21 +152,22 @@ func (q *repoQueue) runQueue() {}for {- shouldReturn := func() (shouldReturn bool) {- // get the next batch- ops := q.nextBatch()- if len(ops) == 0 {- // Nothing left in the queue, so mark not processing and return- if locksVerboseLogging {- log.Printf("[Queue] Queue empty, stopping processing")- }- q.mu.Lock()- q.isProcessing = false- q.mu.Unlock()- return true+ // get the next batch+ ops := q.nextBatch()+ if len(ops) == 0 {+ // Nothing left in the queue, so mark not processing and return+ if locksVerboseLogging {+ log.Printf("[Queue] Queue empty, stopping processing")}+ q.mu.Lock()+ q.isProcessing = false+ q.mu.Unlock()+ return+ }++ firstOp := ops[0]- firstOp := ops[0]+ func() {if locksVerboseLogging {log.Printf("[Queue] Attempting to acquire DB lock for plan %s, branch %s, scope %s",@@ -207,7 +208,9 @@ func (q *repoQueue) runQueue() {}op.done <- fmt.Errorf("failed to get DB lock: %w", err)}- return true+ // we still need to process the rest of the queue+ // if the error is critical, caller will handle it+ return}if locksVerboseLogging {@@ -288,13 +291,7 @@ func (q *repoQueue) runQueue() {log.Printf("[Queue] Rollback completed successfully")}}-- return false}()-- if shouldReturn {- return- }}}diff --git a/app/server/model/plan/build_exec.go b/app/server/model/plan/build_exec.goindex 0521b518..0c404028 100644--- a/app/server/model/plan/build_exec.go+++ b/app/server/model/plan/build_exec.go@@ -3,11 +3,13 @@ package planimport ("fmt""log"+ "net/http""path/filepath""plandex-server/db""plandex-server/hooks""plandex-server/model""plandex-server/types"+ "runtime/debug""time"shared "plandex-shared"@@ -134,6 +136,18 @@ func (buildState *activeBuildStreamState) execPlanBuild(activeBuild *types.Activlog.Printf("Active plan not found for plan ID %s and branch %s\n", planId, branch)return}++ defer func() {+ if r := recover(); r != nil {+ log.Printf("execPlanBuild: Panic: %v\n%s\n", r, string(debug.Stack()))+ activePlan.StreamDoneCh <- &shared.ApiError{+ Type: shared.ApiErrorTypeOther,+ Status: http.StatusInternalServerError,+ Msg: "Panic in execPlanBuild",+ }+ }+ }()+filePath := activeBuild.Pathif !activePlan.IsBuildingByPath[filePath] {diff --git a/app/server/model/plan/tell_exec.go b/app/server/model/plan/tell_exec.goindex 5623da40..52560702 100644--- a/app/server/model/plan/tell_exec.go+++ b/app/server/model/plan/tell_exec.go@@ -4,6 +4,7 @@ import ("fmt""log""net/http"+ "runtime/debug""time""plandex-server/db"@@ -86,6 +87,17 @@ func execTellPlan(params execTellPlanParams) {return}+ defer func() {+ if r := recover(); r != nil {+ log.Printf("execTellPlan: Panic: %v\n%s\n", r, string(debug.Stack()))+ active.StreamDoneCh <- &shared.ApiError{+ Type: shared.ApiErrorTypeOther,+ Status: http.StatusInternalServerError,+ Msg: "Panic in execTellPlan",+ }+ }+ }()+if missingFileResponse == "" {log.Println("Executing WillExecPlanHook")_, apiErr := hooks.ExecHook(hooks.WillExecPlan, hooks.HookParams{diff --git a/app/server/model/plan/tell_stream_main.go b/app/server/model/plan/tell_stream_main.goindex 5ce2e4d8..7dd3adcf 100644--- a/app/server/model/plan/tell_stream_main.go+++ b/app/server/model/plan/tell_stream_main.go@@ -3,7 +3,9 @@ package planimport ("fmt""log"+ "net/http""plandex-server/model"+ "runtime/debug""time"shared "plandex-shared"@@ -25,6 +27,17 @@ func (state *activeTellStreamState) listenStream(stream *model.ExtendedChatComplreturn}+ defer func() {+ if r := recover(); r != nil {+ log.Printf("listenStream: Panic: %v\n%s\n", r, string(debug.Stack()))+ active.StreamDoneCh <- &shared.ApiError{+ Type: shared.ApiErrorTypeOther,+ Status: http.StatusInternalServerError,+ Msg: "Panic in listenStream",+ }+ }+ }()+state.chunkProcessor = &chunkProcessor{replyOperations: []*shared.Operation{},chunksReceived: 0,diff --git a/app/server/model/plan/tell_stream_processor.go b/app/server/model/plan/tell_stream_processor.goindex 303377fd..50b511ce 100644--- a/app/server/model/plan/tell_stream_processor.go+++ b/app/server/model/plan/tell_stream_processor.go@@ -7,6 +7,7 @@ import ("plandex-server/db""plandex-server/types""regexp"+ "runtime/debug""strings""time"@@ -38,6 +39,18 @@ func (state *activeTellStreamState) processChunk(choice types.ExtendedChatComplereturn processChunkResult{}}+ defer func() {+ if r := recover(); r != nil {+ log.Printf("processChunk: Panic: %v\n%s\n", r, string(debug.Stack()))++ active.StreamDoneCh <- &shared.ApiError{+ Type: shared.ApiErrorTypeOther,+ Status: http.StatusInternalServerError,+ Msg: "Panic in processChunk",+ }+ }+ }()+delta := choice.Deltacontent := delta.Contentdiff --git a/app/shared/plan_result_exec_history.go b/app/shared/plan_result_exec_history.goindex 411b1472..f1e10014 100644--- a/app/shared/plan_result_exec_history.go+++ b/app/shared/plan_result_exec_history.go@@ -3,6 +3,10 @@ package sharedfunc (state *CurrentPlanState) ExecHistory() string {execHistory := ""+ if state.PlanResult == nil {+ return execHistory+ }+for _, result := range state.PlanResult.Results {if result.Path == "_apply.sh" && result.AppliedAt != nil {execHistory += "Previously executed _apply.sh:\n\n```\n" + result.Content + "\n```\n\n"diff --git a/releases/server/versions/2.0.3.md b/releases/server/versions/2.0.3.mdnew file mode 100644index 00000000..cc7ff7f9--- /dev/null+++ b/releases/server/versions/2.0.3.md@@ -0,0 +1,3 @@+- Fix for potential crash during chat/tell operation.+- Panic handling to prevent crashes in general.+- Fix for local queue handling bug during builds that could cause queue to get stuck and cause subsequent operations to hang.\ No newline at end of file