node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

for .. in loop for Array is causing errors when Array.prototype is extended

Open molda opened this issue 2 years ago • 2 comments

On this line https://github.com/oracle/node-oracledb/blob/afb9f696ca7dbdd72150ba5efdc94f3ebffb4133/lib/thin/sqlnet/ezConnectResolver.js#L223 the for...in loop is used which causes an error when Array.prototype is extended since it iterates over the added methods.

Changing the for...in to for...of fixes the issue.

The framework i use Total.js framework v4 is extending the Array prototype by many useful methods.

Example without Total.js:

% node
Welcome to Node.js v20.10.0.
Type ".help" for more information.
> for (const a in [1]) console.log(a)
1

Example with Total.js:

Welcome to Node.js v20.10.0.
Type ".help" for more information.
> require('total4')
> for (const a in [1]) console.log(a)
0
take
first
toObject
last
quicksort
trim
skip
findAll
findValue
findItem
remove
wait
async
random
limit

molda avatar Mar 13 '24 15:03 molda

Thanks @molda. We will fix it in the next release after looking at how the for loop has been used.

Were you using the Total.js framework with our previous releases?

sharadraju avatar Mar 14 '24 03:03 sharadraju

Thanks @sharadraju for the quick answer. No i never used oracledb before.

molda avatar Mar 14 '24 07:03 molda

This has been fixed in the 6.5 release. @molda Please verify.

sharadraju avatar May 03 '24 04:05 sharadraju

Thank you @sharadraju I'll test it when i have time and report back if needed.

molda avatar May 03 '24 06:05 molda