Replies: 1 comment 4 replies
-
是因为入口用了 get 吧,应该用 getAsync,如无特殊情况,都应该是 getAsync |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the problem(描述问题)
文档中,初始化
async init()
是一个异步函数,但是在需要使用多实例的情况下,如果使用async init()
作为初始化函数,会出现错误MidwayUseWrongMethodError: 78b4cfc8f0c36c17a30736320d85679a not valid by context.get, Use context.getAsync instead!
,通过 Debug 发现,该错误是由于将init()
标记成 async 导致,midwayjs 代码片段:midway/packages/core/src/definitions/objectCreator.ts
Lines 90 to 100 in a7ffc35
临时解决方案:
将
async init()
修改为init()
,去掉 async 声明,但在第一次初始化服务工厂时,由于initClients(..)
也时一个 async 函数,所以会先有一个未找到服务的错误。Midway Versions(Midway 版本)
"@midwayjs/core": "^3.12.0",
Beta Was this translation helpful? Give feedback.
All reactions