Commit Graph
21 Commits
Author SHA1 Message Date
Linden 11b21f8ed2 refactor(db): rename serverReady variable 2023-06-13 02:23:33 +10:00
Linden 5a949b9546 fix(database): throw Error before creating promise
Promises, even when resolved/rejected immediately after their creation, will
destroy any useful information from a stack trace when used over
events/exports.

Since some people still use the exports rather than MySQL/lib.lua, and for
some reason don't know the correct syntax for Lua exports (i.e. using
exports.oxmysql.query instead of the CORRECT exports.oxmysql:query) it's
comically common for an "untraceable" error to get spit out.

Will this help? No. Will everyone expect me to solve their issues? Yes.

Go update your scripts to use MySQL/lib.lua and we can all get along
stress-free.
2022-11-18 08:58:43 +11:00
Linden bc8a874743 refactor(database): waitForConnection 2022-11-08 17:29:05 +11:00
Linden 8fe63bc88a chore: update dependencies and patch 2022-09-21 13:57:55 +10:00
Linden d80615bddc fix(db): handle errors during callbacks
Handles errors that would previously disappear into the void or show as 'undefined'.

In Lua this would only occur if yielding during the query callback response.

Cross runtime error handling is suffering.
2022-06-26 04:02:50 +10:00
Niek fd8ab04f1a fix(error-events): Add invokingResource to error data (#129) 2022-06-26 04:01:05 +10:00
Linden 5fc56caddf fix(db/rawQuery): handle uncaught promise
oxmysql is unexpectedly catching errors thrown by the Lua runtime
when an error occurs during a function reference.
This lead to an 'undefined' error being thrown, specifically when
yielding a thread during the function reference.

Not really an oxmysql bug, so this should just be a temporary workaround.
2022-06-24 14:14:37 +10:00
Niek 655ee7309f feature: Add event to error handling (#128) 2022-06-22 02:32:22 +10:00
Linden 15884fbc82 refactor: error handling
Meant to push this before release.
Ensures errors are handled as before, regardless of using exports
or lib/mysql; for compatibility.
2022-06-18 16:32:07 +10:00
Linden bccd6a1035 fix: error handling when using callbacks
Only allow manual error handling when using the await/sync methods,
or when calling the default exports.

Async/Callback returns need to throw errors for compatibility.
2022-06-17 21:40:27 +10:00
Linden 340ca48012 refactor: error handling
Add boolean to disable throwing error for query.
Reject promises when using _async exports.
Return errors as strings instead of Error (fails to serialise).

Fixes #122
2022-06-04 14:50:49 +10:00
Linden 56729ef9c1 fix(db): ignore errors during ref call 2022-05-12 08:49:29 +10:00
Linden 050eef58b9 fix(execute): revert to promise api
Several reports of increased chances to hit a deadlock since v2.2.2, and
three reports of a timeout during prepare since v2.2.4.
Simpler to revert to the old prepare function and api (with improvements)
than to work out the solution.

Look into rewriting prepare in the future or including the mariadb connector,
which doesn't suffer from the same perf issues.
2022-04-03 06:10:13 +11:00
Linden c9e402ccdc fix(query): less verbose errors 2022-04-02 01:37:56 +11:00
Linden 3582e72122 refactor(execute): use transactions and parse values
Parse each value while iterating prepared statements, ensuring
objects are remapped to arrays and NULL values are properly
inserted.

Utilise transactions to rollback changes in the event of an error.
2022-03-25 19:00:29 +11:00
Linden dea98f7c5b refactor(database): move from mysql2/promise to callback api
Micro-optimisation for rawQuery. rawExecute and rawTransaction will
still utilise the promise api (pool.promise()).
2022-03-25 06:07:57 +00:00
Linden dd05cb8e68 refactor(database): response is always a callback now 2022-03-25 05:38:18 +00:00
Linden afc04fc553 fix(db): move query responses to their own try block
Other resources with script errors (notably "attempt to index a nil value") would mistakenly report the query as failed, and people would assume ANY reported errors were because of oxmysql, even through it was their own awful script.

No errors should be thrown in oxmysql when an error occurs in a function reference.
2022-03-07 15:13:07 +11:00
Linden ec53b3282d refactor(utils/scheduleTick): Await database connection 2022-02-25 17:11:28 +11:00
Linden 2ea78f1b1b Merge branch 'refactor' into main 2022-02-14 22:23:28 +11:00
dunak-debug 4498dddbac WIP: Rewrite to TS & Cleanup 2021-12-26 02:21:46 +01:00