Skip to content

Commit de1c717

Browse files
authored
[Storage] Removed use of native Node 18 blobs (#6705)
1 parent 46596de commit de1c717

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

.changeset/chilled-forks-accept.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@firebase/storage": patch
3+
---
4+
5+
Fixed issue where clients using Node.js v18 would use the native `Blob` object which is incompatible with `node-fetch`

packages/storage/src/implementation/type.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { isNode } from '@firebase/util';
1819
import { invalidArgument } from './error';
1920

2021
export function isJustDef<T>(p: T | null | undefined): p is T | null {
@@ -39,7 +40,9 @@ export function isNativeBlob(p: unknown): p is Blob {
3940
}
4041

4142
export function isNativeBlobDefined(): boolean {
42-
return typeof Blob !== 'undefined';
43+
// Note: The `isNode()` check can be removed when `node-fetch` adds native Blob support
44+
// PR: https://github.com/node-fetch/node-fetch/pull/1664
45+
return typeof Blob !== 'undefined' && !isNode();
4346
}
4447

4548
export function validateNumber(

packages/storage/test/unit/task.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ describe('Firebase Storage > Upload Task', () => {
505505

506506
// Function that notifies when we are in the middle of an exponential backoff
507507
const readyToCancel = new Promise<null>(resolve => {
508+
// @ts-ignore The types for `stub.callsFake` is incompatible with types of `clock.setTimeout`
508509
stub.callsFake((fn, timeout) => {
509510
// @ts-ignore The types for `stub.callsFake` is incompatible with types of `clock.setTimeout`
510511
const res = fakeSetTimeout(fn, timeout);

0 commit comments

Comments
 (0)