Skip to content

Signal exhaustion of top-level callbacks with a user prompt #134

@lionel-

Description

@lionel-

Code running at top-level might cause new output:

later::later(~ message("foo"), 1)
> foo

Or:

later::later(~ stop("foo"), 1)
> later: exception occurred while executing callback:
Evaluation error: foo.

When that is the case the REPL appears to be hanging because there is no trailing prompt after the output. This gives users the impression that R is busy.

This also causes issues in ESS where the only means of communication with R is trough the process output. If later causes new output at top-level without issuing a prompt, ESS will incorrectly consider R to be busy. Among other problems this stalls the evaluation queue.

Other handlers for running code outside the REPL such as options(error = ) or addTaskCallback() do not have this problem.

To fix this, perhaps later could output the prompt once the last callback has finished running:

cat(paste0("\n", getOption("prompt")))

This would signal users and ESS that R is ready to receive new commands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions