refactor: streamline application startup and IPC service management#65
refactor: streamline application startup and IPC service management#65Seele-Official merged 5 commits intoclice-io:mainfrom
Conversation
📝 WalkthroughWalkthroughRefactored application startup and IPC service management by extracting configuration logic and service implementation from Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/catter/core/app_config.cc`:
- Around line 58-76: load_script_content currently opens script_path verbatim,
so relative paths are resolved against the original process CWD instead of the
configured working_dir; update load_script_content to detect when script_path is
relative (e.g., does not start with '/' or a drive letter on Windows) and
join/resolve it against the configured working_dir (the same working_dir used to
set the JS runtime pwd) before checking internal_scripts or opening the file,
ensuring internal_scripts lookup still works for names like "script::cdb" and
file I/O uses the resolved path.
In `@src/catter/core/app_runner.cc`:
- Around line 126-145: The startup working directory from plan is only applied
to js::init_qjs but not to the service execution, so the proxy/build commands
still run in the original CWD; update run to ensure plan.working_dir is applied
when launching the service by either (A) changing the process CWD before calling
execute_service (e.g., chdir to plan.working_dir) or (B) passing
plan.working_dir into execute_service and having execute_service use it for
proxy/build command invocations; modify the run function and the execute_service
signature/usage (or the config passed into js::on_finish) so the service/proxy
inherits plan.working_dir rather than the original process working directory.
- Around line 90-108: The function inject uses config.buildSystemCommand.front()
without checking if the vector is empty, which can crash when js::on_start()
returns an empty command; update inject(const js::CatterConfig&) to first test
config.buildSystemCommand.empty() and handle that case (e.g., log an error via
your logging facility and return a sensible non-zero int64_t error code or
construct a safe fallback command) before constructing
Session::ProcessLaunchPlan; ensure references to buildSystemCommand.front() are
only used after the guard and update any related code paths
(Session::ProcessLaunchPlan construction, append_range_to_vector call, and
Session::make_run_plan usage) to operate correctly when the command vector was
empty.
In `@src/catter/core/session.cc`:
- Around line 34-44: When the process launch (spawn_task) fails we must ensure
the accept loop (loop_task) is torn down so accept() can unblock; change the
post-run handling so you first attempt to get spawn_task.result() inside a
try/catch, and on catch request cancellation/stop of loop_task (e.g. call the
loop_task cancel/request_stop/stop API or signal the acceptor) then run the
default_loop again to let loop_task unwind, rethrow the spawn exception,
otherwise (if spawn succeeded) call loop_task.result() to propagate loop
exceptions and return spawn_task.result(); reference loop_task, spawn_task,
loop(), spawn(), default_loop().run(), and
loop_task.result()/spawn_task.result() when making the changes.
In `@tests/integration/test/catter-proxy.cc`:
- Around line 111-114: The test currently ignores the session exit code and
always returns 0; update the end of the test to fail on non-zero session exit by
checking the return value from Session::make_run_plan / session.run (the
variable ret) and propagate or assert on it instead of unconditionally returning
0 — e.g. if ret != 0 then return ret (or call std::terminate/assert) so a
non-zero session.run() causes the test to fail.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8a627633-3823-4c98-bb83-7d79cbfe17a5
📒 Files selected for processing (8)
src/catter/core/app_config.ccsrc/catter/core/app_config.hsrc/catter/core/app_runner.ccsrc/catter/core/app_runner.hsrc/catter/core/session.ccsrc/catter/core/session.hsrc/catter/main.cctests/integration/test/catter-proxy.cc
Summary by CodeRabbit
Bug Fixes
Refactor