fix(rag): defensive import for execa in auto-update#1086
Conversation
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Makes execa an optional dependency so RAG auto-update doesn’t fail in projects that don’t install it.
Changes:
- Replaces static
execaimport with a defensive dynamic import. - Skips the drift check when
execaisn’t available and returns a reason.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Defensive import — execa may not be available in projects that only | ||
| // use kj as an external CLI (they don't list it in their own deps). | ||
| let execa; | ||
| try { execa = (await import("execa")).execa; } catch { execa = null; } |
| // Defensive import — execa may not be available in projects that only | ||
| // use kj as an external CLI (they don't list it in their own deps). | ||
| let execa; | ||
| try { execa = (await import("execa")).execa; } catch { execa = null; } |
| // execa not available → skip RAG drift check (non-blocking, see KJC-BUG-0082) | ||
| if (!execa) return { skipped: true, reason: "execa not available" }; |
- Make execa import dynamic to avoid crashes when kj is used as external CLI - Skip RAG drift check gracefully when execa is not available - Fixes KJC-BUG-0082: RAG auto-update fails in projects without execa as direct dependency
68227c8 to
8f7055b
Compare
Resolving Copilot Review Comments✅ Comment 1 - Lazy-load execa: Changed from top-level await to lazy-loading with caching inside ✅ Comment 2 - Error handling: Now only catches module-not-found errors (ERR_MODULE_NOT_FOUND or "Cannot find module"), rethrows other unexpected errors instead of silently swallowing them. ✅ Comment 3 - Logging: Added |
Summary
execaimport dynamic to avoid crashes when kj is used as external CLIRelated