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

【代码问题】未知原因导致副作用重复触发 #17157

Closed
1 task done
GrinZero opened this issue Oct 16, 2024 · 2 comments
Closed
1 task done

【代码问题】未知原因导致副作用重复触发 #17157

GrinZero opened this issue Oct 16, 2024 · 2 comments
Labels
RSS bug Something isn't working

Comments

@GrinZero
Copy link
Contributor

路由地址

NOROUTE

完整路由地址

NOROUTE

相关文档

Any

预期是什么?

我尝试在 lib/utils/ofetch 这个文件中添加了有副作用的代码用于启动 devtools,但是 devtools 不断报错。
经过 debugger,我添加了这一部分代码:
image

尝试发现,是因为存在循环引用导致的函数副作用被二次触发。对应的位置应该在这里:
image

我想询问一下这部分代码能否被移动到其他地方以解决循环引用问题。因为我理解中,这或许会导致 ofetch 文件导出的 rofetch 出现无法预知的行为。

实际发生了什么?

即便使用了动态导入,实际上并没有解决循环引用导致的 ofetch.ts 存在的副作用隐患。可能导致导出的 rofetch 对象存在未知行为。

部署

RSSHub 演示 (https://rsshub.app)

部署相关信息

No response

额外信息

register Error
    at <anonymous> (/Users/bugyaluwang/Desktop/my-projects/RSSHub/lib/utils/ofetch.ts:6:25)
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)
register Error
    at logger (/Users/bugyaluwang/Desktop/my-projects/RSSHub/lib/utils/ofetch.ts:6:25)
    at Object.<anonymous> (/Users/bugyaluwang/Desktop/my-projects/RSSHub/lib/utils/ofetch.ts:35:16)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Object.transformer (/Users/bugyaluwang/Desktop/my-projects/RSSHub/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/register-DpmFHar1.cjs:2:1186)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at ofetch (/Users/bugyaluwang/Desktop/my-projects/RSSHub/lib/utils/got.ts:2:20)
    at Object.<anonymous> (/Users/bugyaluwang/Desktop/my-projects/RSSHub/lib/utils/got.ts:86:27)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Object.transformer (/Users/bugyaluwang/Desktop/my-projects/RSSHub/node_modules/.pnpm/[email protected]/node_modules/tsx/dist/register-DpmFHar1.cjs:2:1186)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)

这不是重复的 issue

  • 我已经搜索了 现有 issue,以确保该错误尚未被报告。
@GrinZero GrinZero added the RSS bug Something isn't working label Oct 16, 2024
@GrinZero GrinZero changed the title 【代码问题】循环引用导致副作用重复触发 【代码问题】未知原因导致副作用重复触发 Oct 18, 2024
@GrinZero
Copy link
Contributor Author

很抱歉得到了错误的结论,目前未知是什么原因导致重复触发

@GrinZero
Copy link
Contributor Author

link -> privatenumber/tsx#499

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

No branches or pull requests

1 participant