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] MainContentLayout-868bfdc8.js:1 TypeError: window.commonEventFunc is not a function at We.login (open-im-sdk-wasm-3b339908.js:1:25495) #128

Closed
wang22290 opened this issue Sep 3, 2024 · 15 comments

Comments

@wang22290
Copy link

OpenIM Server Version

3.8.0

Operating System and CPU Architecture

macOS (ARM)

Deployment Method

Source Code Deployment

Bug Description and Steps to Reproduce

image

I’m using an Electron demo that references open-im-sdk-web-wasm 3.8.0. When running the project with npm run dev, no errors occur. However, after packaging the project into a .app file, I get the following error: TypeError: window.commonEventFunc is not a function at We.login (open-im-sdk-wasm-3b339908.js:1:25495), and I’m unable to log in to IMSDK.”

Screenshots Link

No response

@Bloomingg
Copy link
Member

Did you move the openIM.wasm file?

@wang22290
Copy link
Author

Did you move the openIM.wasm file?

No ,I am using an Electron demo and using Electron Forge to package the project without changing any code.

@Bloomingg
Copy link
Member

So you are not using the official demo, maybe you can refer to the official electon demo. Your problem is because the openIM.wasm file is not loaded correctly.

@wang22290
Copy link
Author

So you are not using the official demo, maybe you can refer to the official electon demo. Your problem is because the openIM.wasm file is not loaded correctly.

I didn't understand what you meant. I used the Electron Demo on GitHub, but I just packaged it into an. app file using the Electron Forge tool and installed it on my Mac computer,

image

@Bloomingg
Copy link
Member

You need to make sure that the packaged file can still be loaded correctly into the wasm file. In fact, the dev and prod environments are somewhat different. For example, the following processing is done in openim-electron-demo. You may need to check your actual import path.

@wang22290
Copy link
Author

You need to make sure that the packaged file can still be loaded correctly into the wasm file. In fact, the dev and prod environments are somewhat different. For example, the following processing is done in openim-electron-demo. You may need to check your actual import path.

I modified the path as you suggested, but still reported the same error,
image

@Bloomingg
Copy link
Member

actually, I don’t mean to ask you to change the path to the same path as mine… Because the basic framework structure of your project may not be the same as the demo, the key point is how to find the correct import path that belongs to your project structure.

@wang22290
Copy link
Author

actually, I don’t mean to ask you to change the path to the same path as mine… Because the basic framework structure of your project may not be the same as the demo, the key point is how to find the correct import path that belongs to your project structure.

I have discovered another issue where the openIMwasm file in the dist file generated by my build cannot be properly packaged into the. app project, as shown in the picture. I have tried to modify the packaging configuration, but it still does not take effect
image

image

image

@PineSongCN
Copy link

我这边是网页版报了类似的错误,原因是nginx的mine.types缺少wasm的类型,没有正确识别解析wasm文件导致的。
https://juejin.cn/post/7410710728783298611

@OpenIM-Robot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I reported a similar error on the web version. The reason is that nginx's mine.types lacks the wasm type and does not correctly identify and parse the wasm file.
https://juejin.cn/post/7410710728783298611

@wang22290
Copy link
Author

actually, I don’t mean to ask you to change the path to the same path as mine… Because the basic framework structure of your project may not be the same as the demo, the key point is how to find the correct import path that belongs to your project structure.

@Bloomingg

I modified the package directory of openIM.wasm. I can get the correct address directly under the Resources file, but window.commonEventFunc is not a function still exists.

I found that Electron may have file path problems, especially in production environments, where file:// protocol paths cannot be loaded directly using the browser environment.

Is this error related to this?

image
image

@Bloomingg
Copy link
Member

you can update you sdk and try again.

npm i @openim/wasm-client-sdk@latest

@wang22290
Copy link
Author

you can update you sdk and try again.

npm i @openim/wasm-client-sdk@latest

@Bloomingg

I used the latest version of openIMSDK ("@openim/wasm-client-sdk": "^3.8.1",) and the Electron Demo from github, and packaged it into an app file with Electron Forge, but still got an error.

image

@wang22290
Copy link
Author

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

I reported a similar error on the web version. The reason is that nginx's mine.types lacks the wasm type and does not correctly identify and parse the wasm file. https://juejin.cn/post/7410710728783298611

我使用的是Electron Demo。我没有理解这个配置该如何修改

@Bloomingg
Copy link
Member

the latest version is 3.8.2-beta.2

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

4 participants