mapbox / pbf

A low-level, lightweight protocol buffers implementation in JavaScript.
BSD 3-Clause "New" or "Revised" License
796 stars 106 forks source link

gtfs realtime pbf is empty? #131

Closed terrafrost closed 2 months ago

terrafrost commented 2 years ago

I'm using a JavaScript module generated by this library for GTFS Realtime to load https://data.texas.gov/Transportation/CapMetro-Vehicle-Positions-PB-File/eiei-9rpf and the result I'm getting back is empty.

Here's my code:

fetch('https://data.texas.gov/download/eiei-9rpf/application%2Foctet-stream', {mode: 'no-cors'}).then(function(result) {
    var bufferRes = result.arrayBuffer();
    var pbf = new Pbf(new Uint8Array(bufferRes));
    var obj = FeedMessage.read(pbf);
    console.log(obj.entity);
});

The console.log() output is [].

Here it is on JS fiddle:

https://jsfiddle.net/opb6deqL/

Am I doing something wrong or maybe the GTFS Realtime dataset I'm trying to pull data from is malformed or something? Downloading https://data.texas.gov/download/eiei-9rpf/application%2Foctet-stream gets me a 25KB file so it's clearly not empty. And given that the PB file has been downloaded 186M times it's hard to believe that it's malformed and no one has ever noticed. Most likely, I'm probably doing something wrong but idk what.

Thanks!

mourner commented 2 months ago

Sorry for not responding in time. This looks like an issue with the API itself — in the fiddle, if you console.log the buffer itself, it's empty, so it's nothing to do with pbf. Not sure how to solve this but closing.