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

由于无法使用createBundleRenderer,没有vue ssr自带沙箱机制。应该怎么清除setTimeout之类的副作用 #69

Closed
ekxs0109 opened this issue May 31, 2022 · 3 comments

Comments

@ekxs0109
Copy link
Contributor

缓慢看了下genesis 的代码,genesis里的沙箱中用在了远程模块加载时。但对vue服务端渲染没有进行隔离... 如果在某个组件内使用了setInterval,会导致服务端无限制执行

20220531195246

@lzxb
Copy link
Contributor

lzxb commented Jun 1, 2022

你有兴趣的话,可以看下这里的代码:
https://github.com/fmfe/genesis/blob/master/packages/genesis-core/src/node-vm.ts
https://github.com/vuejs/vue/blob/main/packages/server-renderer/src/bundle-renderer/create-bundle-runner.ts#L45

其实Vue官方的实现也是没有实现的,这个我考虑过要实现,你有兴趣的话,可以尝试自己实现,然后提交个PR过来。

@lzxb
Copy link
Contributor

lzxb commented Jun 1, 2022

之前尝试过使用Proxy实现,但是遇到了一点问题,所以就没有处理了。

@ekxs0109
Copy link
Contributor Author

ekxs0109 commented Jun 1, 2022

了解了,谢谢解答。我试试proxy下setTimeout setInterval 。

@lzxb lzxb closed this as completed Jun 2, 2022
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

No branches or pull requests

2 participants