Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout maxBuffer length exceeded. #101

Closed
bamf-admin opened this issue May 8, 2023 · 3 comments
Closed

stdout maxBuffer length exceeded. #101

bamf-admin opened this issue May 8, 2023 · 3 comments
Labels

Comments

@bamf-admin
Copy link

bamf-admin commented May 8, 2023

Hi! I'm trying to convert US Zip Code Shapefile data to GeoJSON. My short script is below:

// ./index.js
const ogr2ogr = require('ogr2ogr').default
const fs = require('fs');

(async() => {
  let { stream } = await ogr2ogr('./input/tl_2022_us_zcta520 - most current available zip code shape files.zip');

  let { text } = await ogr2ogr(stream, { format: 'GeoJSON', maxBuffer: 1024 * 1024 * 1024 * 1024 });

  fs.writeFile('./output/zipcodes.json', text, (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
  });
  
})();

Simple enough. I'm trying to convert a ~500MB file. I've adjusted the maxBuffer to have 1GB of buffer space, but I still get the following error when running:

$ node index.js
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
    at new NodeError (node:internal/errors:399:5)
    at Socket.onChildStdout (node:child_process:487:14)
    at Socket.emit (node:events:512:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:293:11)
    at Readable.push (node:internal/streams/readable:234:10)
    at Pipe.onStreamRead (node:internal/stream_base_commons:190:23) {
  code: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',
  cmd: 'ogr2ogr -f GeoJSON -skipfailures /vsistdout/ /vsizip/./input/tl_2022_us_zcta520 - most current available zip code shape files.zip'
}

Node.js v19.8.1

Any ideas? It doesn't look like the actual CMD is receiving any flags about the altered buffer size...

@wavded
Copy link
Owner

wavded commented May 9, 2023

The first command doesn't specify any buffer size and is unneeded it looks like, try running this:

// ./index.js
const ogr2ogr = require('ogr2ogr').default
const fs = require('fs');

(async() => {
  let { text } = await ogr2ogr('./input/tl_2022_us_zcta520 - most current available zip code shape files.zip',
    { format: 'GeoJSON', maxBuffer: 1024 * 1024 * 1024 * 1024 });

  fs.writeFile('./output/zipcodes.json', text, (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
  });
})();

@github-actions
Copy link

github-actions bot commented Jun 9, 2023

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the stale label Jun 9, 2023
@github-actions
Copy link

This issue was closed because it has been stalled for 5 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants