Skip to content

[Storage] Removed use of native Node 18 blobs #6705

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

Merged
merged 6 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-forks-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/storage": patch
---

Fixed issue where clients using Node.js v18 would use the native `Blob` object which is incompatible with `node-fetch`
5 changes: 4 additions & 1 deletion packages/storage/src/implementation/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

import { isNodeSdk } from '@firebase/util';
import { invalidArgument } from './error';

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

export function isNativeBlobDefined(): boolean {
return typeof Blob !== 'undefined';
// Note: The `isNodeSdk()` check can be removed when `ts-node` adds native Blob support
// PR: https://github.com/node-fetch/node-fetch/pull/1664
return typeof Blob !== 'undefined' && !isNodeSdk();
}

export function validateNumber(
Expand Down
1 change: 1 addition & 0 deletions packages/storage/test/unit/task.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ describe('Firebase Storage > Upload Task', () => {

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