azure-sdk-for-js: DisableResponseDecompressionPolicy error with electron app using azure sdk from angular renderer
I have a desktop app that uses electron and angular. I am trying to upload the Blob storage using @azure/storage-blob
in the angular renderer process. When uploadData method is called library will just crash with following error:
Error: Uncaught (in promise): Error: DisableResponseDecompressionPolicy is not supported in browser environment
Error: DisableResponseDecompressionPolicy is not supported in browser environment
Please note I am using nodeIntegration: true when opening the angular portal like below:
this.mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
},
});
From my understanding is that disableResponseDecompressionPolicy is only available in Node.js but this is a common use case where angular apps running inside an electron shell need to communicate with azure-storage. Can we get more clarity on this issue, whether this is a limit in the SDK and how can angular app inside electron work
old issue: https://github.com/Azure/azure-sdk-for-js/issues/14025
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (12 by maintainers)
Hi @jeremymeng ,
Any chance to Iadd a browser version isNode implementation which always returns false, would this cause any potential issues?
Thanks Emma
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage.
Issue Details
I have a desktop app that uses electron and angular. I am trying to upload the Blob storage using
@azure/storage-blob
in the angular renderer process. When uploadData method is called library will just crash with following error:Please note I am using nodeIntegration: true when opening the angular portal like below:
From my understanding is that disableResponseDecompressionPolicy is only available in Node.js but this is a common use case where angular apps running inside an electron shell need to communicate with azure-storage. Can we get more clarity on this issue, whether this is a limit in the SDK and how can angular app inside electron work
old issue: https://github.com/Azure/azure-sdk-for-js/issues/14025
bug
,customer-reported
,Client
,Storage
,Service Attention
@gingi :
I think the issue is because: The bundler dectects it’s a browserfy environment and choses the browser version
DisableResponseCompressionPolicy
definition whenisNode()
is not invoked yet. While in runtime,isNode()
is invoked and returnstrue
due to configure ofnodeIntegration: true
Hi @jeremymeng ,
I may understand the issue wrong, please correct me if I’m wrong.
The issue here is: when customer set
nodeIntegration: true
,isNode
which detects the environment in runtime would return true, but the file is picked up in compiling and the compiler thinks it’s a browser.I see we only support
disableResponseDecompressionPolicy
in Node.JS, because we have no control on whether to decompress response content in Browser environment.If customer sets
nodeIntegration: true
, do we have control on on whether to decompress response content? If anyway, we cannot control it, I think maybe ignoring thedisableResponseDecompressionPolicy
setting with a warning is a good way to go.Thanks Emma
Storage only uses
disableResponseDecompressionPolicy
when determined it’s Node.js environment in runtime, but seems for Electron it still selects the browser path.@jeremymeng , any suggestions how we could deal with this situation?
Thanks Emma