tedious icon indicating copy to clipboard operation
tedious copied to clipboard

Exception thrown from SmallDateTime/generateParameterData cannot be caught properly

Open tidhar-ziv opened this issue 4 years ago • 1 comments

This exception was thrown due to a query date parameter earlier than "1900/01/01":

RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 65535. Received -1
    at checkInt (internal/buffer.js:69:11)
    at writeU_Int16LE (internal/buffer.js:719:3)
    at Buffer.writeUInt16LE (internal/buffer.js:727:10)
    at Object.generateParameterData (C:\Users\i025052\projects\playground\node_modules\tedious\lib\data-types\smalldatetime.js:53:12)
    at generateParameterData.next (<anonymous>)
    at RpcRequestPayload.generateParameterData (C:\Users\i025052\projects\playground\node_modules\tedious\lib\rpcrequest-payload.js:114:17)
    at generateParameterData.next (<anonymous>)
    at RpcRequestPayload.generateData (C:\Users\i025052\projects\playground\node_modules\tedious\lib\rpcrequest-payload.js:68:19)
    at generateData.next (<anonymous>)
    at C:\Users\i025052\projects\playground\node_modules\readable-stream\lib\internal\streams\from.js:43:35 {
  code: 'ERR_OUT_OF_RANGE'
}

The problem is that this exception is thrown on the main thread, so the only way to catch it is in process.on("uncaughtException"), which practically means crashing the process

tidhar-ziv avatar May 20 '21 19:05 tidhar-ziv

@tidhar-ziv Thanks for raising this issue, we'll see if we can create a fix!

IanChokS avatar May 21 '21 17:05 IanChokS