mcollina / mcollina/split2

Does backpressure is handled in split2 as its is resulting for me in heap memory limit error

Open
#55 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
296
Forks
25
PR merge metrics
No merged PRs in 30d

Description

Below code snippet is resulting into heap memory exhaustion.

try {
  const downloadedFile = this._s3client.getObject(params) 
  const userStream: Readable = await downloadedFile.createReadStream()

  for await (const userId of pipeline(userStream, split2(), piplineCallback)) {
    console.log(userId)
  }

} catch (error) {
  console.log('Error should be caught here.')
  throw error
}

const piplineCallback = (err) => {
  if (err) {
    logger.error({ exception: err }, 'Error occured in splitted userstream pipeline.')
    throw new InternalServerError(err)
  } else {
    logger.debug('Userstream pipeline succeded.')
  }
}

This code results into following error:

"FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory\n"

I am using node.js v12.x
Do I need to handle backpressure explicity here somehow?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported Node.js v12 snippet, especially split2(), pipeline(), and the S3 createReadStream() source. Reproduce the heap exhaustion and inspect the stream/backpressure behavior; done means establishing whether split2 is responsible and documenting the required handling or a confirmed defect.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, stream-processing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.