plandex-ai/plandex · error

panic in LoadCachedFileMapHandler: %v %s

Error message

panic in LoadCachedFileMapHandler: %v
%s

What it means

Recovery guard in LoadCachedFileMapHandler's per-path goroutine: a panic occurred while loading a cached file map. Panic value and stack are logged and sent to errCh; Goexit prevents double-send to the channel.

Source

Thrown at app/server/handlers/file_maps.go:140

	}

	var req shared.LoadCachedFileMapRequest
	if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
		http.Error(w, fmt.Sprintf("Error decoding request: %v", err), http.StatusBadRequest)
		return
	}

	cachedMetaByPath := map[string]*shared.Context{}
	cachedMapsByPath := map[string]*db.CachedMap{}
	var mu sync.Mutex
	errCh := make(chan error, len(req.FilePaths))

	for _, path := range req.FilePaths {
		go func(path string) {
			defer func() {
				if r := recover(); r != nil {
					log.Printf("panic in LoadCachedFileMapHandler: %v\n%s", r, debug.Stack())
					errCh <- fmt.Errorf("panic in LoadCachedFileMapHandler: %v\n%s", r, debug.Stack())
					runtime.Goexit() // don't allow outer function to continue and double-send to channel
				}
			}()

			cachedContext, err := db.GetCachedMap(plan.OrgId, plan.ProjectId, path)
			if err != nil {
				errCh <- fmt.Errorf("error getting cached map: %v", err)
				return
			}
			if cachedContext != nil {
				mu.Lock()
				cachedMetaByPath[path] = cachedContext.ToMeta().ToApi()
				cachedMapsByPath[path] = &db.CachedMap{
					MapParts:  cachedContext.MapParts,
					MapShas:   cachedContext.MapShas,
					MapTokens: cachedContext.MapTokens,
					MapSizes:  cachedContext.MapSizes,
				}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the logged stack trace for the panicking code
  2. Check for nil CachedMap/Context entries for that path
  3. Fix the root cause; recover is only crash protection
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at app/server/handlers/file_maps.go:140 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/5138287f49ede377. Report an issue: GitHub.