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

[storage-file-datalake] Unable to create DataLakeServiceClient Instance in Angular #8499

Closed
NaveenKY opened this issue Apr 23, 2020 · 8 comments · Fixed by #8568
Closed

[storage-file-datalake] Unable to create DataLakeServiceClient Instance in Angular #8499

NaveenKY opened this issue Apr 23, 2020 · 8 comments · Fixed by #8568
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)

Comments

@NaveenKY
Copy link

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)

@ghost ghost added customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Apr 23, 2020
@NaveenKY
Copy link
Author

I have pushed sample code in repository:
https://github.com/NaveenKY/angular-electron-adls

and code is available in this file.

@xirzec xirzec added the Client This issue points to a problem in the data-plane of the library. label Apr 23, 2020
@xirzec xirzec changed the title Unable to create Instance Angular [storage-file-datalake] Unable to create DataLakeServiceClient Instance in Angular Apr 23, 2020
@xirzec xirzec added Storage Storage Service (Queues, Blobs, Files) and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Apr 23, 2020
@jeremymeng
Copy link
Member

we probably need to stub StorageSharedKeyCredential as a class instead of a undefined const

https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/storage/storage-file-datalake/src/credentials/StorageSharedKeyCredential.browser.ts#L4

@jeremymeng jeremymeng added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Apr 27, 2020
@jeremymeng jeremymeng self-assigned this Apr 27, 2020
jeremymeng added a commit to jeremymeng/azure-sdk-for-js that referenced this issue Apr 27, 2020
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.
@jeremymeng
Copy link
Member

@NaveenKY thanks for reporting the issue! Hopefully we will include a fix in the next release of the library (no ETA yet)

@NaveenKY
Copy link
Author

@jeremymeng Is it possible to pull this change manually before release so that i can try integrating it?

@jeremymeng
Copy link
Member

@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.

jeremymeng added a commit that referenced this issue May 1, 2020
)

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 jeremymeng reopened this May 1, 2020
@NaveenKY
Copy link
Author

@jeremymeng As i see you had re-opened this issue, is it still not fixed?

@jeremymeng
Copy link
Member

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

npm i @azure/storage-file-datalake@dev

@ramya-rao-a
Copy link
Contributor

Closing this issue as the latest update 12.0.1 to the @azure/storage-file-datalake package has the fix

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants