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

[BUG]获取脚本存储的值为旧值 #41

Closed
joriscai opened this issue Feb 28, 2022 · 2 comments · Fixed by #42
Closed

[BUG]获取脚本存储的值为旧值 #41

joriscai opened this issue Feb 28, 2022 · 2 comments · Fixed by #42
Labels
bug Something isn't working

Comments

@joriscai
Copy link
Contributor

在调试脚本时,发现GM_getValue每次获取都为旧值。
如下图,值已经修改为字符串的123123,但是获取到还是123(这个值是修改为123123之前的值)
image

image

debug插件源码

通过调试插件源码,发现插件调用了background.js的buildScriptCache方法
image
在buildScriptCache方法中debug,发现resolve的值已经是最新的值了。
image
image
然而在实际获取的返回值,发现是旧的值,如下图:
image

怀疑的问题出现的地方

插件代码中有其他对返回值进行转换?

我测试过firefox,发现firefox也有这个问题,个人比较偏向是插件层做了数据传输过程的转换,从而导致数据前后不一致,但是在查看源码暂时没找到。大佬是否能解答一下?

浏览器的问题

background和前端的代码属于不同进程,进程之间传输数据出错了?

@CodFrm CodFrm added the bug Something isn't working label Feb 28, 2022
@CodFrm
Copy link
Member

CodFrm commented Feb 28, 2022

运行和调试的环境不是同一个,直接点击运行是在background的sandbox页运行的,debug是在前端页面的sandbox页面执行的

因为GM_set/getValue这些是同步的操作,数据库是异步,所以对value做了一个缓存,应该是修改后的消息没到这个前端页面来,缓存没有更新掉导致的,刷新页面应该好了,具体的原因和修复还要看一下,最近有点其它的事情在忙,下个版本可能要在3月初才能修复发布了

background的话有用这个方法去处理
https://github.com/scriptscat/scriptcat/blob/main/src/apps/script/manager.ts#L43

@joriscai
Copy link
Contributor Author

运行和调试的环境不是同一个,直接点击运行是在background的sandbox页运行的,debug是在前端页面的sandbox页面执行的

因为GM_set/getValue这些是同步的操作,数据库是异步,所以对value做了一个缓存,应该是修改后的消息没到这个前端页面来,缓存没有更新掉导致的,刷新页面应该好了,具体的原因和修复还要看一下,最近有点其它的事情在忙,下个版本可能要在3月初才能修复发布了

background的话有用这个方法去处理 https://github.com/scriptscat/scriptcat/blob/main/src/apps/script/manager.ts#L43

哦,原来是这样,我这边研究一下,看看能不能修复了,再提交pr。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants