From 805f00303d1ea019023c3fd44814275d74986d78 Mon Sep 17 00:00:00 2001 From: crockalet Date: Sun, 25 Jan 2026 09:28:33 +0500 Subject: [PATCH 1/3] fix(network-activity-plugin): getFormDataEntries(body).reduce is not a function --- .../src/react-native/http/http-utils.ts | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/packages/network-activity-plugin/src/react-native/http/http-utils.ts b/packages/network-activity-plugin/src/react-native/http/http-utils.ts index 7a7c471..ed60eab 100644 --- a/packages/network-activity-plugin/src/react-native/http/http-utils.ts +++ b/packages/network-activity-plugin/src/react-native/http/http-utils.ts @@ -45,23 +45,30 @@ const getTextPostData = (body: unknown): RequestTextPostData => ({ value: safeStringify(body), }); -const getFormDataPostData = (body: FormData): RequestFormDataPostData => ({ - type: 'form-data', - value: getFormDataEntries(body).reduce( - (acc, [key, value]) => { - if (isBlob(value)) { - acc[key] = getBinaryPostData(value); - } else if (isArrayBuffer(value)) { - acc[key] = getArrayBufferPostData(value); - } else { - acc[key] = getTextPostData(value); - } - - return acc; - }, - {}, - ), -}); +const getFormDataPostData = (body: FormData): RequestFormDataPostData => { + const entries = getFormDataEntries(body); + const entriesArray = ( + Array.isArray(entries) ? entries : Array.from(entries || []) + ) as Array<[string, unknown]>; + + return { + type: 'form-data', + value: entriesArray.reduce( + (acc, [key, value]) => { + if (isBlob(value)) { + acc[key] = getBinaryPostData(value); + } else if (isArrayBuffer(value)) { + acc[key] = getArrayBufferPostData(value); + } else { + acc[key] = getTextPostData(value); + } + + return acc; + }, + {}, + ), + }; +}; export const getRequestBody = (body: XHRPostData): RequestPostData => { if (isNullOrUndefined(body)) { From 83ee95c6957080563cb4c05cc43d9303ee2e2fdf Mon Sep 17 00:00:00 2001 From: crockalet Date: Tue, 27 Jan 2026 09:42:23 +0500 Subject: [PATCH 2/3] refactor(network-activity-plugin): simplify array check --- .../src/react-native/http/http-utils.ts | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/packages/network-activity-plugin/src/react-native/http/http-utils.ts b/packages/network-activity-plugin/src/react-native/http/http-utils.ts index ed60eab..c679785 100644 --- a/packages/network-activity-plugin/src/react-native/http/http-utils.ts +++ b/packages/network-activity-plugin/src/react-native/http/http-utils.ts @@ -45,30 +45,22 @@ const getTextPostData = (body: unknown): RequestTextPostData => ({ value: safeStringify(body), }); -const getFormDataPostData = (body: FormData): RequestFormDataPostData => { - const entries = getFormDataEntries(body); - const entriesArray = ( - Array.isArray(entries) ? entries : Array.from(entries || []) - ) as Array<[string, unknown]>; - - return { - type: 'form-data', - value: entriesArray.reduce( - (acc, [key, value]) => { - if (isBlob(value)) { - acc[key] = getBinaryPostData(value); - } else if (isArrayBuffer(value)) { - acc[key] = getArrayBufferPostData(value); - } else { - acc[key] = getTextPostData(value); - } - - return acc; - }, - {}, - ), - }; -}; +const getFormDataPostData = (body: FormData): RequestFormDataPostData => ({ + type: 'form-data', + value: Array.from(getFormDataEntries(body)).reduce< + RequestFormDataPostData['value'] + >((acc, [key, value]) => { + if (isBlob(value)) { + acc[key] = getBinaryPostData(value); + } else if (isArrayBuffer(value)) { + acc[key] = getArrayBufferPostData(value); + } else { + acc[key] = getTextPostData(value); + } + + return acc; + }, {}), +}); export const getRequestBody = (body: XHRPostData): RequestPostData => { if (isNullOrUndefined(body)) { From 7ef19d6d86454d39a7079e436f2c96842a7c9ace Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Wed, 28 Jan 2026 10:12:52 +0100 Subject: [PATCH 3/3] chore: add version plan --- .nx/version-plans/version-plan-1769591535914.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .nx/version-plans/version-plan-1769591535914.md diff --git a/.nx/version-plans/version-plan-1769591535914.md b/.nx/version-plans/version-plan-1769591535914.md new file mode 100644 index 0000000..c43ff1c --- /dev/null +++ b/.nx/version-plans/version-plan-1769591535914.md @@ -0,0 +1,5 @@ +--- +"@rozenite/network-activity-plugin": patch +--- + +Converted FormData entries iterator to an array before reduce to avoid 'reduce is not a function' and keep request body parsing stable.