-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[storage-file-datalake] Unable to create DataLakeServiceClient
Instance in Angular
#8499
Comments
I have pushed sample code in repository: and code is available in this file. |
DataLakeServiceClient
Instance in Angular
we probably need to stub |
This fixes Azure#8499. The issue was that in `StorageClient.ts` we have the following check and assume that in browser scenario `isNode` would be `false` which would short-circuit the evaluation of `factory instanceof StorageSharedKeyCredential`. So we added an `undefined` const for browser stub of `StorageSharedKeyCredential`. ```typescript if ( (isNode && factory instanceof StorageSharedKeyCredential) || factory instanceof AnonymousCredential || isTokenCredential(factory) ) { this.credential = factory; } `` However, in an Electron + Angular application, `isNode` is `true` but browser files are used. So the condition after `&&` is evaluated and caused an error: ``` TypeError: Right-hand side of 'instanceof' is not an object at DataLakeServiceClient.StorageClient (StorageClient.js:35) at new DataLakeServiceClient (DataLakeServiceClient.js:39) ``` This fix changes the stub of `StorageSharedKeyCredential` to an empty class instead so the condition will not throw but be evaluated to `false` because this credential type is not supported in browser.
@NaveenKY thanks for reporting the issue! Hopefully we will include a fix in the next release of the library (no ETA yet) |
@jeremymeng Is it possible to pull this change manually before release so that i can try integrating it? |
@NaveenKY For testing you can download the tarballs from our CI artifacts. You would probably need several dependencies from the same location as their new versions haven't been released. |
) This fixes #8499. The issue was that in StorageClient.ts we have the following check and assume that in browser scenario isNode would be false which would short-circuit the evaluation of factory instanceof StorageSharedKeyCredential. So we added an undefined const for browser stub of StorageSharedKeyCredential. ```typescript if ( (isNode && factory instanceof StorageSharedKeyCredential) || factory instanceof AnonymousCredential || isTokenCredential(factory) ) { this.credential = factory; } ``` However, in an Electron + Angular application, isNode is true but browser files are used. So the condition after && is evaluated and caused an error: ``` TypeError: Right-hand side of 'instanceof' is not an object at DataLakeServiceClient.StorageClient (StorageClient.js:35) at new DataLakeServiceClient (DataLakeServiceClient.js:39) ``` This fix changes the stub of StorageSharedKeyCredential to an empty class instead so the condition will not throw but be evaluated to false because this credential type is not supported in browser.
@jeremymeng As i see you had re-opened this issue, is it still not fixed? |
It's fixed but I'd like to keep the issue open until we release a version that contains the fix. BTW you can also try out our dev version from npmjs. Currently it is at v12.1.0-dev.20200507.1
|
Closing this issue as the latest update 12.0.1 to the |
I am using angular version 9.0.2 and @azure/storage-file-datalake with version 12.0.0.
Below is the sample line where i am trying to create the new instance of DataLakeServiceClient.
const datalakeServiceClient = new DataLakeServiceClient(
https://${account}.dfs.core.windows.net
,credentials
);
It is failing with below error:
core.js:3866 ERROR Error: Uncaught (in promise): TypeError: Right-hand side of 'instanceof' is not an object
TypeError: Right-hand side of 'instanceof' is not an object
at DataLakeServiceClient.StorageClient (StorageClient.js:35)
at new DataLakeServiceClient (DataLakeServiceClient.js:39)
The text was updated successfully, but these errors were encountered: