cassandra-driver mapper: basic operations RangeError
Hi, so we have a regular NodeJS web app hosted on B1 app plan (linux). Serverless cosmos-db cassandra API used for data persistence, cassandra-driver v4.6.3.
Most of the time everything is fine, works as expected (data write/read), no connection issues. But, occasionally, it throws RangeError during execution of some db operation by driver mapper (e.g. mapper.get( ), mapper.update( ), ...).
Error message example: RangeError: The value of "offset" is out of range. It must be >= 0 and <= 131. Received 132
Only web app restart helps (from azure portal). After app is restarted, same operations no longer throw any errors (for some period of time).
Such error can appear during any mapper operation (get, find, update, create, remove) for any table. Table can be very simple, with a few columns and primitive data types.
Any solutions? Ideas, thoughts, directions? This problem was first noticed six months ago, and no solution was found yet. Thanks in advance!
UPD
I still can't find exact steps to get this error, all i know:
- App deployed and running (no errors), handles all requests.
- Some time passes (several hours or days) - app is still running, no restarts.
- Suddenly RangeError appears while handling some request, where cassandra db operation present.
Example case:
We have webapp1 - it handles http requests to POST /posts (data write). It has request validators, so only correct data can be persisted.
- webapp1 was deployed and started on 02.22
- webapp1 handles all POST /posts requests successfully on 02.22, 02.23, 03.03, 03.10
- webapp1 was updated and deployed on 03.11 (no changes to /posts code)
- webapp1 handles all POST /posts requests successfully on 03.11, 03.15
- webapp1 was updated and deployed on 03.21 (no changes to /posts code)
- webapp1 handles all POST /posts requests successfully on 03.23, 03.24
- on 03.25 all POST /posts requests fail with RangeError
We have data access code like this:
const mapper = new Mapper(new Client(/*options*/), {
models: {
SomeModel: {/*model options*/},
// other models
}
});
// ...
const modelMapper = mapper.forModel(modelName);
// mapper call examples
modelMapper.get({ id }, { fields: ['some_field'] });
modelMapper.update({ ...object });
Example error stack trace:
stack: 'RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 264. Received 266\n' +
' at new NodeError (node:internal/errors:371:5)\n' +
' at boundsError (node:internal/buffer:86:9)\n' +
' at Buffer.readUInt16BE (node:internal/buffer:332:5)\n' +
' at FrameReader.readShort (/home/site/wwwroot/node_modules/cassandra-driver/lib/readers.js:131:29)\n' +
' at FrameReader.readMetadata (/home/site/wwwroot/node_modules/cassandra-driver/lib/readers.js:341:38)\n' +
' at Parser.parseResult (/home/site/wwwroot/node_modules/cassandra-driver/lib/streams.js:326:35)\n' +
' at Parser.parseBody (/home/site/wwwroot/node_modules/cassandra-driver/lib/streams.js:200:19)\n' +
' at Parser._transform (/home/site/wwwroot/node_modules/cassandra-driver/lib/streams.js:152:10)\n' +
' at Parser.Transform._write (node:internal/streams/transform:184:23)\n' +
' at writeOrBuffer (node:internal/streams/writable:389:12)'