wechat-miniprogram / wechat-miniprogram/wx-server-sdk
在云函数本地调试时, 本地云函数无法调用本地云函数
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
问题简述
我有一个按钮,点击会调用 云函数 foo ,而 云函数 foo 又会调用 云函数 bar 。
现在,我想在本地调试 云函数 foo 对 云函数 bar 的调用。
于是,我有如下发现:
- 当 本地云函数 foo 依赖的
wx-server-sdk版本等于3.0.1时,可以正常调用 本地云函数 bar 。 - 而当 本地云函数 foo 依赖的
wx-server-sdk版本大于3.0.1时,调用 本地云函数 bar 会报错:
[error] 函数执行失败(耗时 273ms) Error: callFunction:fail callFunction:fail the reource is not found
问题复现
运行环境
系统: macOS Tahoe (Apple M1 Pro)
微信开发者工具: 2.01.2510290 darwin-arm64
调试基础库: 3.17.0
复现步骤
-
用微信开发者工具,打开此 代码片段 ,打开时需要选择带有云环境的
AppID。 -
打开后,请右击
cloudfunctions目录,确认【当前环境】确实选择了一个云环境。
(虽然此代码片段是为了测试 本地云函数 调用 本地云函数 ,但从我的测试来看,仍然需要云函数选择某个云环境,否则后续步骤会报错) -
右击
cloudfunctions目录,点击【开启云函数本地调试】。 -
在打开的【云函数本地调试】面板中,依次点击左侧边栏的 bar_latest、foo_3_0_1、foo_3_0_2 和 foo_latest 云函数,并依次勾选它们右侧的【开启本地调试】(会提示安装 node modules,点击确认)。
-
接下来就可以点击【foo_3_0_1 调用...】、【foo_3_0_2 调用...】、【foo_latest 调用...】按钮,每点击一次,就观察【云函数本地调试】面板中相关云函数的 Console 控制台。
发现的问题
- foo_3_0_1 虽然调用成功,但是并未像【云函数本地调试功能】中说的那样:本地云函数 foo_3_0_1 的【Network 面板】会展示其对本地云函数 bar_latest 的调用。
参见:云函数本地调试功能
- foo_3_0_2 和 foo_latest 都调用失败,报错信息如下:
[error] 函数执行失败(耗时 237ms) Error: callFunction:fail callFunction:fail the reource is not found
at E (/Users/vincent/WeChatProjects/minicode-9/cloudfunctions/foo_latest/node_modules/@cloudbase/node-sdk/dist/utils/utils.js:31:12)
at processReturn (/Users/vincent/WeChatProjects/minicode-9/cloudfunctions/foo_latest/node_modules/@cloudbase/node-sdk/dist/utils/utils.js:54:11)
at Object.request (/Users/vincent/WeChatProjects/minicode-9/cloudfunctions/foo_latest/node_modules/@cloudbase/node-sdk/dist/utils/tcbapirequester.js:353:16)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async callFunction (/Users/vincent/WeChatProjects/minicode-9/cloudfunctions/foo_latest/node_modules/@cloudbase/node-sdk/dist/functions/index.js:62:12)
at async CloudBase.callFunction (/Users/vincent/WeChatProjects/minicode-9/cloudfunctions/foo_latest/node_modules/@cloudbase/node-sdk/dist/cloudbase.js:202:16)
at async /Users/vincent/WeChatProjects/minicode-9/cloudfunctions/foo_latest/node_modules/wx-server-sdk/index.js:1803:29
最后的疑问
调试 “本地云函数 调用 本地云函数” ,是有什么更好的替代方案我不知道吗?还是说我上述打开方式不对?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the linked code snippet using the cloudfunctions/bar_latest, foo_3_0_1, foo_3_0_2, and foo_latest entry points. Compare wx-server-sdk 3.0.1 with later versions, then inspect the callFunction stack under foo_latest/node_modules/@cloudbase/node-sdk and wx-server-sdk. Done means local foo-to-bar calls work consistently and appear in the documented Network panel.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, cloud, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100