How to safely interrupt a thread in a thread in NodeJS?

I use Requests to transfer the HTTP stream to a local utility for processing geospatial files, ogr2ogr:

httpStream.on('response', function(response) { var ogr = ogr2ogr(response) .skipfailures() .options(['-t_srs', 'EPSG:4326']); 

However, if the file I get is too large, I want to abort:

  response.on('data', function (chunk) { len += chunk.length; if (!abort && len > convert.maxConversionSize) { tooBigError(request, res); abort = true; httpStream.abort(); // response.destroy(); //?? } 

Does httpStream.abort() enough? What exactly happens with the ogr2ogr process? Is it left to hang? What is the correct way to ensure it is cleaned up and somewhere there is no half-filled memory buffer left?

+5
source share

All Articles