The weird problems encountered by geojson

I built a mapping service using nodejs-v8.15.0 and tilestrata-2.1.2, and now I have a weird problem debugging the output of geojson.
my backend code is as follows:

query=`SELECT ST_ASGEOJSON(ST_INTERSECTION( ST_TRANSFORM(ST_SETSRID(way, 900913),4326) , ST_SETSRID(ST_MAKEENVELOPE(121.5966796875,31.12819929911195,121.61865234375,31.109388560814956), 4326) ) ) AS geometry, tags AS properties FROM planet_osm_roads WHERE ST_INTERSECTS( ST_TRANSFORM(ST_SETSRID(way, 900913),4326), ST_SETSRID(ST_MAKEENVELOPE(121.5966796875,31.12819929911195,121.61865234375,31.109388560814956), 4326) ) AND highway <> ""`;

pgPool.query(query, function(err, result) {
    if (err) {
        console.log(query, err.message, err.stack)
        var err = new Error("An error occurred");
        err.statusCode = 500;
        return callback(err);
    }
      
    var outputText = "{"type":"FeatureCollection","features":[" +
        result.rows.map(function(row) {
          if (row.geometry) {
            var featureString = "{"type":"Feature","geometry":" + row.geometry;
            if (row.properties != ""){
                var rowpro = row.properties;
                rowpro = rowpro.replace(/=>/g,":");
                featureString = featureString + ","properties":" + "{"+  rowpro + "}}";
            }
            else{
                featureString = featureString + ","properties":""}";
            }
            delete row;
            return featureString;
          }
    }).join(",") +"]}";
    
    //outputText4372
    callback(null, outputText, {"Content-Type": "application/json"});
});

then type http://192.168.56.180:8767/geojson/14/13726/6700/road.json
in the browser and you will find that the Content-Length in head is 4372, but only 4324 characters are displayed in RAW DATA, and the latter disappears, resulting in an error: SyntaxError: JSON.parse: unterminated string at line 1 column 4325 of the JSON data

not all statements will be truncated, but some will be like this. If I remove this part of the row.properties code, there will be no error, but the outputText generated by adding this part of the row.properties code is correct. When it comes to the browser, it may make an error. I can"t find the rule

.

attachment: the data source is the pbf, of shanghai downloaded by openstreetmap. This problem can be reproduced in me. The browsers are chrome-71.0.3578.80 (64-bit) and firefox-63.0.3 (64-bit), and the data is imported using osm2pgsql.

Please give me some advice from prawns. I have no direction.

Menu