VDF.parse: invalid syntax exception
relm opened this issue · 3 comments
Describe the bug
A "VDF.parse: invalid syntax" exception is being triggered randomly while logged into Steam.
I have my app configured to listen to Steam changelist events and then fetch the product info. It doesn't seem like this error is being triggered by any specific App IDs though, it seems more like something node-steam-user is trying to parse in the background that triggers it, but I've been unable to diagnose what that is so far. Previously, I was running an earlier version (4.26) and had no issues.
I think this was prior to the move to simple-vdf? Looking at the commits, the VDF parser was changed in 4.28.3.
Attached the relevant error details below.
I'm running with the following options. I'm also logging into Steam using a refresh token (not sure if that would matter or not).
this.steam = new SteamUser({
enablePicsCache: true,
changelistUpdateInterval: 30000,
picsCacheAll: true,
dataDirectory: '/shinra/x/app/data',
protocol: SteamUser.EConnectionProtocol.TCP
});
Versions
Node.js v18.12.1 and node-steam-user v4.28.7
Screenshots and Error Logs
/shinra/x/app/node_modules/simple-vdf/index.js:54
throw new SyntaxError("VDF.parse: invalid syntax on line " + (i+1));
^
SyntaxError: VDF.parse: invalid syntax on line 1320
at Object.parse (/shinra/x/app/node_modules/simple-vdf/index.js:54:23)
at /shinra/steam.startropics.net/app/node_modules/steam-user/components/apps.js:242:21
at Array.forEach (<anonymous>)
at SteamUser.<anonymous> (/shinra/x/app/node_modules/steam-user/components/apps.js:233:24)
at SteamUser._handleMessage (/shinra/xapp/node_modules/steam-user/components/03-messages.js:639:35)
at SteamUser._handleNetMessage (/shinra/x/app/node_modules/steam-user/components/03-messages.js:562:8)
at SteamUser._processMulti (/shinra/x/app/node_modules/steam-user/components/03-messages.js:693:9)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
This does sound like some app has invalid vdf going on, at least as far as the simple-vdf parser is concerned. I'd need to know the appid that's triggering the error. Could you open up node_modules/steam-user/components/apps.js and insert this line right after 237:
console.log(`Parsing appinfo for ${app.appid}`);
It should go right after this line:
appInfoVdf = appInfoVdf.replace(/\0$/, '');
Once done, re-run your app and let me know what the last output is before the error happens.
Ok, I left things running overnight and received the error again.
The last output before the error is the following:
Parsing appinfo for 230290
It seems to be reproducible. I tried running getProductInfo on that AppID specifically and it caused a crash with the same error message.
Great, thanks for the repro case. Looks like simple-vdf breaks if a string contains a newline.
I wrote my own VDF parser yesterday since all the ones on npm suck in various ways. Update to 4.28.8 to get the fix.