Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4682

Refactor ReadableCursorStream to use Node's Readable.from [post-v6]

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      The Node driver currently maintains a custom NodeJS stream adapter for cursors.  Starting in Node15, NodeJS has a `Readable.from` method which can adapt an async iterator to a NodeJS stream automatically.

      We should consider dropping support for this custom type in favor of the NodeJS builtin.  Our ReadableStream is an internal type, so it can be removed in any release.

      To make this change now, we need to maintain support for Readable.from ourselves.  The NodeJS source is available here and looks straightforward to maintain (our implementation would be even simpler, since we would only support async iterables).

       

      Acceptance Criteria

      • Implement a custom Readable.from method based on the NodeJS source to use in our cursors.  We should only use our polyfilled version if NodeJS <= 15, otherwise we rely on the Node builtin.
      • Remove ReadableCursorStream and use Readable.from instead.

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: