Capture and relay call frames on errors

未关闭
#478 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
20/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
r

调研方向

首先检查 FutureResult 对象以及 .traceback(NULL)、.traceback(2L) 和 utils::dump.frames() 周围的错误处理路径。考虑提议的 future.recover.enable 选项和顺序 futures,确定 worker 的 recover 栈是否可以在父 R 进程中记录并重新生成。完成的标准是行为和配置已定义,并且转发的错误会公开捕获的 call frames。

由索引模型根据 Issue 内容生成。

描述

Idea

> options(error = function() utils::recover())
> foo <- function(x, a = 2) a * x
> f <- future(foo("y"))
> v <- value(f)
Error in a * x : non-numeric argument to binary operator
Enter a frame number, or 0 to exit   
1: foo("y")
2: HenrikBengtsson/future-ideas#1: (function () 
utils::recover())()

Selection: 1
Called from: top level 
Browse[1]> ls.str()
a :  num 2
x :  chr "y"
Browse[1]> 

The idea is to have the future record the full recover stack in the FutureResult object. Something like the info in:

tb <- .traceback(NULL)
if (is.null(tb)) tb <- .traceback(2L)
utils::dump.frames(dumpto = "frames", to.file = FALSE)

and then regenerate this call stack when relaying the error on the parent R process. I'm not sure if/not the latter can be done, but if we can figure it out, it'll be super cool.

It might be expensive to transfer all call stacks back from the worker to the main R session when running in parallel, so maybe this needs to be enabled via an option, e.g. options(future.recover.enable = TRUE). It might be that we can enable it by default for sequential futures.

See also

https://github.com/HenrikBengtsson/future/issues/253

主要语言
R
星标
1k
派生
93
平均合并
2 天 4 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

futureverse/future 的其他 Issue

查看 futureverse/future 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。