protobuf.js version: 6.8.4
I am trying to decode a buffer and getting the error below
Here is the buffer I saved : https://github.com/andiwonder/dota_gc/blob/master/node-dota2/test.txt
using
fs.writeFileSync(__dirname + "/test.txt", body, "binary");;
The proto I am using is : https://github.com/andiwonder/dota_gc/blob/master/node-dota2/proto/dota_match_metadata.proto
https://github.com/andiwonder/dota_gc/blob/master/node-dota2/scratch.js
var fs = require('fs');
const ProtoBuf = require('protobufjs');
var path = require('path');
var buffer = fs.readFileSync((path.join(__dirname) + '/test2.txt'));
console.log('buffer length is ' + buffer.byteLength);
var builder = ProtoBuf.loadSync(path.join(__dirname) + '/proto/dota_match_metadata.proto');
var decoded_message = builder.CDOTAMatchMetadata.decode(buffer);
var json = decoded_message(JSON.stringify(decoded_message));
console.log(json);
and I am getting the error below :

Can you tell me what is going wrong, is my buffer corrupted or is there something wrong with the proto. Any help is appreciated.
fs.writeFileSync(__dirname + "/test.txt", body, "binary");;
Doesn't that return a binary string instead of a proper buffer? See also: https://github.com/dcodeIO/protobuf.js/wiki/How-to-read-binary-data-in-the-browser-or-under-node.js%3F
Well even when I try to decode it directly (without writing/reading from a file) I still get the same error.
The code https://github.com/andiwonder/dota_gc/blob/master/node-dota2/index.js#L165
var builder = Protobuf.loadSync(path.join(__dirname) + '/proto/dota_match_metadata.proto');
var decoded_message = builder.CDOTAMatchMetadata.decode(Buffer.from(body));
var json = decoded_message(JSON.stringify(decoded_message));
console.log(json);

Might also be that the buffer is actually invalid or the .proto definition does not match. You could try to inspect it by hand to get more insights.
Most helpful comment
Might also be that the buffer is actually invalid or the .proto definition does not match. You could try to inspect it by hand to get more insights.