Fixing it comes down to understanding what is going wrong. Once you know what is wrong, you automatically know the way it should be.
Rather than saying exactly what needs to be changed to fix it, I hope to show you how to find out for yourself.
If this is the first time you've come across a stacktrace, here's how to read this one.
It starts like this:
C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Parser.js:82
throw err;
^
a 'Parser' inside a mysql library throws an error; that tells you some SQL query is failing.
Next it goes on to explain the err (^
):
Error: number format error: empty string
The error is that a number is not formatted properly, because it is an empty string. It is like handing a function a blank piece of paper when it expects a number to be written onto it. But it isn't, so it doesn't know what to do, and raises an Error.
So now we know what is going wrong - at a low level. Let's see where it is going wrong, so that we know why.
We find this in the stacktrace: the function calls, all the way from the beginning of the program, to where the error was raised:
at Error (native)
This first line says that this error orinates in an Error function at some place called 'native': somewhere within the execution environment (the javascript engine), not in the program being executed.
This doesn't give us any new context - we know there is an error already.
at Function.Long.fromString (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\node_modules\long\dist\Long.js:180:19)
Here, we get something related to numbers: it seems to be a function converting a string to a Long
, which is a type of large number. Not much news here either, as the error message told us empty string
already. But at least we are on the right track.
at toAccountId (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:376:15)
Here we see that the number/string is probably an 'account id', used in the stream-tradeoffers module. For now let's assume that the empty string is passed to this function, and in the process of converting it to an account id it is turned into a number. Before we want to debug third party modules, lets first see if the problem is not in the main program:
at SteamTradeOffers.makeOffer (C:\Users\Frederik\Desktop\bot\node_modules\steam-tradeoffers\index.js:396:42)
Again the library, followed by:
at Query._callback (C:\Users\Frederik\Desktop\bot\sell.js:160:13)
In OP's pastebin we find at that line:
offers.makeOffer ({
partnerSteamId: row[i].userid,
itemsFromMe: item,
accessToken: row[i].token,
itemsFromThem: [],
message: 'Congratulations! You won a game on '+sitename+'. Your game ID is #'+gamenum
}, function(err,response){....
Here we find the call to makeOffer
, and what parameters are used. It is likely that one of them is the empty string, or is an object with an empty-string property that is read by the makeOffer
method; to find out, we'd have to check files mentioned in the previous two stacktrace lines.
To save time, we don't really need to look at the rest of the stack trace, since from here on it only references the mysql
library, and it's unlikely the problem is there:
at Query.Sequence.end (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
at Query._handleFinalResultPacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Query.js:144:8)
at Query.EofPacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\sequences\Query.js:128:8)
at Protocol._parsePacket (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Protocol.js:271:23)
at Parser.write (C:\Users\Frederik\Desktop\bot\node_modules\mysql\lib\protocol\Parser.js:77:12)