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

mqtt.js无法使用:TypeError: Cannot set property 'AbortSignal' of undefined #15580

Closed
QyInvoLing opened this issue Apr 24, 2024 · 2 comments
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@QyInvoLing
Copy link

相关平台

微信小程序

复现仓库

https://github.com/QyInvoLing/minimal-taro-mqtt.git
小程序基础库: 3.4.1
使用框架: Vue 3

复现步骤

执行pnpm run dev:weapp命令后使用微信开发者工具打开小程序即可

期望结果

正常运行

实际结果

 TypeError: Cannot set property 'AbortSignal' of undefined
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:1821
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:377
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:5537
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:377
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:6052
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:377
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:6146
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:377
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:6373
    at vendors-node_modules_taro_weapp_prebundle_mqtt_js.js?t=wechat&s=1713965264626&v=966ecdee403aa4cda6446fa88e8aad11:377(env: Windows,mp,1.06.2402040; lib: 3.4.1)```

### 环境信息

Taro CLI 3.6.26 environment info:
System:
OS: Windows 11 10.0.22621
Binaries:
Node: 20.8.1 - C:\Program Files\nodejs\node.EXE
npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
@tarojs/cli: 3.6.26 => 3.6.26
@tarojs/components: 3.6.26 => 3.6.26
@tarojs/helper: 3.6.26 => 3.6.26
@tarojs/plugin-framework-vue3: 3.6.26 => 3.6.26
@tarojs/plugin-platform-alipay: 3.6.26 => 3.6.26
@tarojs/plugin-platform-h5: 3.6.26 => 3.6.26
@tarojs/plugin-platform-jd: 3.6.26 => 3.6.26
@tarojs/plugin-platform-qq: 3.6.26 => 3.6.26
@tarojs/plugin-platform-swan: 3.6.26 => 3.6.26
@tarojs/plugin-platform-tt: 3.6.26 => 3.6.26
@tarojs/plugin-platform-weapp: 3.6.26 => 3.6.26
@tarojs/runtime: 3.6.26 => 3.6.26
@tarojs/shared: 3.6.26 => 3.6.26
@tarojs/taro: 3.6.26 => 3.6.26
@tarojs/taro-loader: 3.6.26 => 3.6.26
@tarojs/webpack5-runner: 3.6.26 => 3.6.26
babel-preset-taro: 3.6.26 => 3.6.26
eslint-config-taro: 3.6.26 => 3.6.26


<!-- generated by taro-issues. 请勿修改或删除此行注释 --><!--labels=T-weapp,V-3,F-vue3-->
@taro-bot2 taro-bot2 bot added F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Apr 24, 2024
@Typeve
Copy link

Typeve commented Apr 29, 2024

这个应该是mqtt版本的问题,我之前使用uniapp时遇到过。
emqx建议版本
这里建议使用 原生微信小程序 MQTT.js 可用版本有 v4.2.1、v4.2.0、v4.1.0 和 v2.18.8

@QyInvoLing
Copy link
Author

这个应该是mqtt版本的问题,我之前使用uniapp时遇到过。 emqx建议版本 这里建议使用 原生微信小程序 MQTT.js 可用版本有 v4.2.1、v4.2.0、v4.1.0 和 v2.18.8

这几个版本我都试过了,都缺少浏览器环境中的WebSocket对象,解决方案是修改4.x的mqtt.min.js,在其中自己封装一个

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-vue3 Framework - Vue 3 T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
Archived in project
Development

No branches or pull requests

2 participants