Skip to content

Commit 0e61824

Browse files
committed
Revert "fix: update serializeUploadOptions option to based on options runtime types"
This reverts commit 914d289.
1 parent 914d289 commit 0e61824

File tree

3 files changed

+10
-36
lines changed

3 files changed

+10
-36
lines changed

packages/aws-amplify/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@
515515
"name": "[Storage] uploadData (S3)",
516516
"path": "./dist/esm/storage/index.mjs",
517517
"import": "{ uploadData }",
518-
"limit": "22.99 kB"
518+
"limit": "22.95 kB"
519519
}
520520
]
521521
}

packages/storage/__tests__/providers/s3/apis/internal/uploadData/multipartHandlers.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,6 @@ const mockListParts = jest.mocked(listParts);
5757
const mockHeadObject = jest.mocked(headObject);
5858
const mockCalculateContentCRC32 = jest.mocked(calculateContentCRC32);
5959

60-
// Hack to make sure jest mocked defaultStorage is not serializable. So it will not change the options hash.
61-
Object.setPrototypeOf(
62-
defaultStorage,
63-
Object.getPrototypeOf(jest.requireActual('@aws-amplify/core').defaultStorage),
64-
);
65-
6660
const disableAssertionFlag = true;
6761

6862
const MB = 1024 * 1024;

packages/storage/src/providers/s3/apis/internal/uploadData/multipart/uploadCache.ts

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,42 +99,22 @@ const listCachedUploadTasks = async (
9999
};
100100

101101
/**
102-
* Serialize the uploadData API options to string so it can be hashed. The following options will be OMITTED from the
103-
* result. It only checks the top-level options assuming we do not use unserializable types in nested properties by
104-
* design.
105-
* * undefined
106-
* * bigint
107-
* * function
108-
* * symbol
109-
* * class instances except for Array.
102+
* Serialize the uploadData API options to string so it can be hashed.
110103
*/
111104
export const serializeUploadOptions = (
112105
options: UploadDataWithPathInputWithAdvancedOptions['options'] & {
113106
resumableUploadsCache?: KeyValueStorageInterface;
114107
} = {},
115108
): string => {
116-
const isSerializable = (value: any): boolean => {
117-
const valueType = typeof value;
118-
if (['bigint', 'function', 'symbol', 'undefined'].includes(valueType)) {
119-
return false;
120-
}
121-
if (valueType === 'object') {
122-
if (
123-
value === null ||
124-
Object.getPrototypeOf(value) === Object.prototype ||
125-
Object.getPrototypeOf(value) === Array.prototype
126-
) {
127-
return true; // null/array/plain objects
128-
}
129-
130-
return false;
131-
}
132-
133-
return true; // string/number/boolean
134-
};
135-
109+
const unserializableOptionProperties: string[] = [
110+
'onProgress',
111+
'resumableUploadsCache', // Internally injected implementation not set by customers
112+
'locationCredentialsProvider', // Internally injected implementation not set by customers
113+
] satisfies (keyof typeof options)[];
136114
const serializableOptions = Object.fromEntries(
137-
Object.entries(options).filter(([_, value]) => isSerializable(value)),
115+
Object.entries(options).filter(
116+
([key]) => !unserializableOptionProperties.includes(key),
117+
),
138118
);
139119

140120
return JSON.stringify(serializableOptions);

0 commit comments

Comments
 (0)