Skip to content

Feature Request: Implement pause/resume for request streams #89

Closed

Description

@dhensby

I'm helping to maintain node-mssql and the tedious driver has recently added pause/resume functions to their requests which has allowed us to pass this functionality on.

Pausing and resuming request streams is very useful when dealing with extremely large datasets as it allows the application to back-off when processing of rows can't keep up with the speed they are returned (usually resulting in out of memory errors).

Ideally I'd like to implement true node streams in node-mssql but I can't do this without the sqlserver-v8 driver providing this back-off functionality.

Activity

  1. TimelordUK commented on Jan 8, 2019

    @TimelordUK
    Owner
  2. self-assigned this
    on Jan 8, 2019
  3. dhensby commented on Mar 8, 2019

    @dhensby
    ContributorAuthor

    So I guess it all depends on what is needed

    Sorry for delay on this. From our point of view we just need to be able to reliably apply backpressure to a stream (ie: pause and resume it on demand). I'm not too bothered about concurrency (though that would be nice).

  4. TimelordUK commented on May 26, 2019

    @TimelordUK
    Owner

    this should be available in 0.7.2

      test('pause a large query every 100 rows', testDone => {
        let expected = 0
        const q0 = theConnection.query(`select * from syscolumns`)
        q0.on('row', () => {
          ++expected
        })
        let rows = 0
        const q = theConnection.query(`select * from syscolumns`)
        q.on('error', (e) => {
          assert.ifError(e)
        })
        q.on('row', () => {
          ++rows
          if (rows % 100 === 0) {
            q.pauseQuery()
            setTimeout(() => {
              q.resumeQuery()
            }, 200)
          }
        })
        q.on('done', () => {
          assert.strictEqual(expected, rows)
          testDone()
        })
      })
  5. dhensby commented on May 31, 2019

    @dhensby
    ContributorAuthor

    Thanks for this @TimelordUK - I've opened a PR to add the pause/resume feature to our v8 adapter. However it seems to be failing in our appveyor builds for node v6 and v8 (v10 is running, at least).

    Any ideas what the difference would be?

  6. dhensby commented on May 31, 2019

    @dhensby
    ContributorAuthor

    Ah - I just noticed in v0.7.1 you dropped node <10 support. The package.json for this lib needs updating, then.

  7. TimelordUK commented on May 31, 2019

    @TimelordUK
    Owner
  8. dhensby commented on Aug 7, 2019

    @dhensby
    ContributorAuthor

    This is now done 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions