Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clone function in core/util should guard against circular reference, otherwise stack overflow may occur in valid usecases #1066

Open
li6in9muyou opened this issue Mar 11, 2024 · 0 comments · May be fixed by #1067

Comments

@li6in9muyou
Copy link

li6in9muyou commented Mar 11, 2024

This is issue is repeated in a echarts issue as well.
util 里面里的克隆函数应该防范环形引用,否则一些很合理的场景会抛出栈溢出异常,然后图表就不能显示了,这个 issue 我在 echarts 也提了。

我意见就是添加在 util.ts 里面添加一个全局变量,用 weakset ,只把克隆过程中遇到的对象放进去,递归前检查当前对象是否已经在这个 weakset 里面,如果在的话就不递归下去了。我就是不知道这样随意添加一个全局变量合适不合适,这个是模块私有的变量,应该也没问题。

[Bug] Circular reference in series.data causes stack overflow thus chart fails to show

  1. paste the follow code in to echarts official example editor
  2. open dev tool, read latest exception
const root = {
  name: "root",
  value: 20,
  children: []
};
const a = {
  name: "a",
  value: 10,
  parent: root
};
root.children.push(a);

option = {
  series: {
    type: 'sunburst',
    data: [root]
  }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant