jeremydaly / data-api-client

A "DocumentClient" for the Amazon Aurora Serverless Data API
MIT License
444 stars 63 forks source link

Error tracing issues #114

Open ffxsam opened 2 years ago

ffxsam commented 2 years ago

Has anyone else noticed your stack traces don't seem to go back as far as they should when there's a SQL error?

    "stack": [
        "BadRequestException: Number of characters in SQLStatement is longer than 65536",
        "    at Object.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:52:27)",
        "    at Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/rest_json.js:55:8)",
        "    at Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:106:20)",
        "    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:78:10)",
        "    at Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:688:14)",
        "    at Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
        "    at AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
        "    at /var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
        "    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
        "    at Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:690:12)"
    ]

I wonder why it starts within the AWS SDK library, and not my actual code. Anyone know? It makes it incredibly difficult to debug issues.

cnnrmtthws commented 2 years ago

I'm not sure what the underlying reason is but it looks like a general problem with errors from the AWS JS SDK https://github.com/aws/aws-sdk-js/issues/1358. A comment on that issue says that it has been fixed in the v3 SDK as it needed a major version change https://github.com/aws/aws-sdk-js/issues/1358#issuecomment-754494140

ffxsam commented 2 years ago

I've patched my own personal version of data-api-client to use the v3 SDK. I'll have to pay attention to whether db errors trace differently now.