Skip to content

send_at background process dies when parent R session exits #8

@NewGraphEnvironment

Description

@NewGraphEnvironment

Problem

send_at uses callr::r_bg() to schedule background sends. When the parent R process exits (e.g., Rscript -e completing), the child process is killed before it can send. This means send_at only works from interactive R sessions or scripts that explicitly keep the parent alive with a while(proc$is_alive()) Sys.sleep(10) loop.

Discovered during live testing — three scheduled sends all died silently when the spawning Rscript exited.

Proposed Solution

Test these approaches in order:

  1. callr::r_bg(supervise = FALSE) — may detach child from parent lifecycle
  2. system2("Rscript", ..., wait = FALSE) — write a temp .R script and launch as a fully independent process
  3. Document the limitation — if detaching isn't reliable, document that send_at requires the parent session to stay alive

Also related: the send_log and send_notify features (added in #2) now make silent failures visible, but the process still needs to survive to log anything.

Relates to NewGraphEnvironment/sred-2025-2026#1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions