-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
- What versions are you using?
Oracle Database in Amazon RDS versions 19.0.0.0.ru-2022-01.rur-2022-01.r1 and 19.0.0.0.ru-2022-10.rur-2022-10.r1 (multiple similar databases)
> process.platform
'darwin'
> process.version
'v19.9.0'
> process.arch
'x64'
> require('oracledb').versionString
'6.0.1'
- Is it an error or a hang or a crash?
Error - the wrong data is returned. The script also hangs occasionally but I haven't been able to trace down that error
- What error(s) or behavior you are seeing?
I have a database table with a CLOB column containing JSON data. I'm fetching thousands of records from that table (using oracledb.fetchAsString = [oracledb.CLOB];) and occasionally (roughly 1 in 7000 records) one of those rows comes back such that the JSON value has extra characters prepended. Those characters appear to represent the length of the field. So for example I have a row where the JSON column contains 2875 bytes. The library is instead giving me a 2877-byte string starting with bytes 0b 3b 7b 22 69 74 65 . . . (0x0b3b is equal to 2875).
This issue is new to node-oracledb v6 - it doesn't happen on v5.5.0
I've traced this through the library and I believe it's coming from packet.js. Specifically L157 starts a chunked read which defines a buffer for the results to go into. Inside that chunked read is a call to readUB4, which calls readBytes. I believe this error happens on occasions where the UB4 read spans between the current chunk and the next chunk, so readBytes starts a new chunked read on L225 and reads the length of the buffer. But it doesn't clean up after itself so the length of the buffer remains at the beginning of the chunked read buffer and gets returned.