github overextended/oxmysql v2.3.4

latest releases: v2.12.0, v2.11.2, v2.11.1...
2 years ago

Corrects some unexpected cross-runtime error handling. Take the following example, where we attempt to index a nil value.

MySQL.query('SELECT 1', {}, function()
    MySQL.query.await('SELECT 1')
    local t = {}
    print(t[1].value)
end)

[ script:oxmysql] SCRIPT ERROR in promise (unhandled): Error: test was unable to execute a query!
[ script:oxmysql] undefined
[ script:oxmysql] SELECT 1 []

With this changeset will now return the script error and stack trace.

[ script:oxmysql] SCRIPT ERROR: @test/server.lua:76: attempt to index a nil value (field 'integer index')
[ script:oxmysql] > ref (@test/server.lua:76)
[ script:oxmysql] > (@oxmysql/dist/build.js:21745)
[ script:oxmysql] > processTicksAndRejections (node:internal/process/task_queues:96)
[ script:oxmysql] > async rawQuery (@oxmysql/dist/build.js:21735)
[ script:oxmysql]

This behaviour only presents itself when yielding a thread during a callback function reference; that is:

  • using Citizen.Wait or Citizen.Await
  • using the await / sync MySQL methods

New events will now be triggered when an error occurs, which may be useful for third-party logging (i.e. datadog, sentry).

AddEventHandler('oxmysql:error', function(data)
    print(data.query)
    print(json.encode(data.parameters))
    print(data.message)
    print(data.err)
    print(data.invokingResource)
end)

Bug Fixes

  • db/rawQuery: handle uncaught promise (Linden)
  • error-events: Add invokingResource to error data (#129) #129 (Niek)
  • utils/parseTransaction: check for array (Linden)
  • db: handle errors during callbacks (Linden)
  • update: return if current version is higher than release (Linden)

Commits

Don't miss a new oxmysql release

NewReleases is sending notifications on new releases.