Skip to content

Commit

Permalink
[Storage] Change browser stub of StorageSharedKeyCredential to class
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jeremymeng committed Apr 27, 2020
1 parent 2e3cf69 commit a732e77
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export const StorageSharedKeyCredential = undefined;
export class StorageSharedKeyCredential {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export const StorageSharedKeyCredential = undefined;
export class StorageSharedKeyCredential {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export const StorageSharedKeyCredential = undefined;
export class StorageSharedKeyCredential {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

export const StorageSharedKeyCredential = undefined;
export class StorageSharedKeyCredential {}

0 comments on commit a732e77

Please sign in to comment.