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

Unknown error: <nil> when using connection.execute() with local vars

Open svetlasyrimis opened this issue 3 years ago • 4 comments

Hi,

Observing frustratingly vague error and I am trying to understand what causes it:

  InternalServerErrorException: unknown error: <nil>

The code that causes it; I opted for having dynamic values like that:

await conn.execute('SET @id = 1; SELECT * from table where id = @id;', [])

However if I instead switch it to the snippet below, it works

await conn.execute('SELECT * from table where id = ?;', [1])

.query() doesn't have this problem, however, I'd like to use .execute()

svetlasyrimis avatar May 18 '22 16:05 svetlasyrimis

Where this error is coming from? Is that coming directly from exception in await conn.execute() ? Can you share a stack trace?

sidorares avatar May 18 '22 23:05 sidorares

@sidorares stack is not very verbose either; Yes it is coming directly from await conn.execute()

Error: unknown error: <nil>
    at PromiseConnection.execute (path/to/project/.webpack/service/src/lambda-entry-point.js:13318:22)
    at MysqlDataAccessService.initializeConnection (/path/to/project/.webpack/service/src/main.js:982:34)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

error obj -

code:'ER_UNKNOWN_ERROR'
errno:1105
message:'unknown error: <nil>'
sql:'SET @id = 1; SELECT * from table where id = @id;'
sqlMessage:'unknown error: <nil>'
sqlState:'HY000'

svetlasyrimis avatar May 19 '22 16:05 svetlasyrimis

Hey @sidorares any insights into the issue?

svetlasyrimis avatar May 23 '22 11:05 svetlasyrimis

sorry for silence @svetlasyrimis

Can you try the same with non-promise api and see if the error if different?

sidorares avatar May 30 '22 02:05 sidorares