-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Amplify PubSub - Production builds do not open websocket #7554
Comments
I managed to put a breakpoint in the Below, the production-minified code of the Amplify function, with some watchers : |
Ok, I found it... The This import is clearly specified in the documentation, and the initialization should be performed as this: However, following strictly this documentation will not work in production builds, because minifiers will drop the unused PubSub import because it is actually never used in my I fixed my app by forcing the registration before calling addPluggable, or artificially using the PubSub module in my boot function. Below the both working hacks: PubSub.getModuleName();
Amplify.addPluggable(
new AWSIoTProvider({
aws_pubsub_region: '',
aws_pubsub_endpoint: ''
})
); Amplify.register(PubSub);
Amplify.addPluggable(
new AWSIoTProvider({
aws_pubsub_region: '',
aws_pubsub_endpoint: ''
})
); I guess the documentation should be updated to warn about this side effect, or the behavior of addPluggable may be improved to prevent minifiers missing the register() function call before Amplify.addPluggable. |
Thanks for reporting this @npellegrin and digging into the problem/solution. I am encountering the same issue with vite production build and react. The above fix(es) work for me as well. versions "aws-amplify": "^5.2.2"
"vite": "^3.2.3" |
Moving this issue to the |
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
PubSub
Amplify Categories
Not applicable
Environment information
Describe the bug
This may be related to aws-amplify/amplify-js#10829.
It could be related to my implementation of the Amplify initialization in Quasar.
When using the PubSub module, websockets are not opened by the framework with production builds. There is no error message.
Development builds works properly.
Expected behavior
Websockets should be opened on both development build and production builds.
Reproduction steps
I have a Vue.js application, built with Vite and Quasar. Versions are:
I setup Amplify during the Quasar boot and the Amplify init looks like this:
And the subscription is performed like this:
Also, I have in my index.html and quasar.config.js the magic lines to make Amplify work with production packaging:
index.html
quasar.config.js:
When testing the application with
quasar dev
, the subscription is performed.With a production build, the websocket request is never opened by the web browser, but no error message is shown.
Additional information and screenshots
With
Amplify.Logger.LOG_LEVEL = 'DEBUG'
activated, production builds have no reference to MqttOverWSProvider in the logs, when dev builds properly show the MqttOverWSProvider, and it work.I found a possible workaround, it seems that adding the AWSIoTProvider pluggable directly using the PubSub API instead of using the Amplify API API works:
The text was updated successfully, but these errors were encountered: