Skip to content
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

RangeError: Too many properties to enumerate when uploading #971

Open
Cafe137 opened this issue Nov 1, 2024 · 1 comment
Open

RangeError: Too many properties to enumerate when uploading #971

Cafe137 opened this issue Nov 1, 2024 · 1 comment
Assignees

Comments

@Cafe137
Copy link
Collaborator

Cafe137 commented Nov 1, 2024

RangeError: Too many properties to enumerate
    at Function.keys (<anonymous>)
    at Object.isEmptyObject (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/utils.js:134:24)
    at getMergedValue (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/core/mergeConfig.js:21:22)
    at valueFromConfig2 (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/core/mergeConfig.js:43:14)
    at computeConfigValue (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/core/mergeConfig.js:98:23)
    at Object.forEach (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/utils.js:281:10)
    at mergeConfig (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/core/mergeConfig.js:96:9)
    at Axios.request (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/core/Axios.js:41:12)
    at wrap (/Users/aron/Code/Swarm/swarmwiki/node_modules/axios/lib/helpers/bind.js:5:15)
    at http (file:///Users/aron/Code/Swarm/swarmwiki/node_modules/@ethersphere/bee-js/dist/mjs/utils/http.js:23:28)

The file that triggers this:

X/fulltext/xapian 356114432 application/octet-stream+xapian

When Bee-JS code transforms the request configuration (including body) before handing it over to the HTTP client (axios), I suspect that the body is not detected as data but as a JS object instead, and it wrongly prepares it by extracting all of its indices (1 byte each if it is a Buffer/ArrayBuffer/Uint8Array/etc.) to the merged object.

Edit: see the comment below, the problem may not be in bee-js.

I see this error rarely, and IIRC it is always binary large files (threshold somewhere around 100 or 300MB).

@Cafe137 Cafe137 self-assigned this Nov 1, 2024
@Cafe137
Copy link
Collaborator Author

Cafe137 commented Nov 6, 2024

(Probably) a different variation of this is the following:

RangeError: Invalid array length
    at Function.keys (<anonymous>)
    at Object.isEmptyObject (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/utils.js:134:24)
    at getMergedValue (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/core/mergeConfig.js:21:22)
    at valueFromConfig2 (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/core/mergeConfig.js:43:14)
    at computeConfigValue (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/core/mergeConfig.js:98:23)
    at Object.forEach (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/utils.js:281:10)
    at mergeConfig (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/core/mergeConfig.js:96:9)
    at Axios.request (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/core/Axios.js:41:12)
    at wrap (/Users/aron/Code/Swarm/sandbox/node_modules/axios/lib/helpers/bind.js:5:15)
    at http (/Users/aron/Code/Swarm/sandbox/node_modules/@ethersphere/bee-js/dist/cjs/utils/http.js:32:52)

This is the axios function that triggers it:

/**
 * Determine if a value is a empty Object
 *
 * @param {Object} val The value to test
 * @return {boolean} True if value is a empty Object, otherwise false
 */
function isEmptyObject(val) {
  return val && Object.keys(val).length === 0 && Object.getPrototypeOf(val) === Object.prototype;
}

This is val that gets passed:

<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 149999950 more bytes>

This seems to be an axios bug, in which it tries to determine if a buffer is an object, and calling Object.keys on it kills the JS runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant