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

Import snappy dependency lazily when feature is used

    • 3
    • Not Needed
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Motivation

      We want to move the import (requiring) of dependencies into the part of the driver that utilizes the feature that the extension offers. Other than FLE, we currently have all our dependencies set up for lazy usage but not lazy import. FLE's import occurs when the autoEncrypter options are specified on a MongoClient. Example: I should be able to assert that if I do not enable AWS authentication that the AWS peerOptionalDependency the driver needs for this auth is not attempted to be imported.

      • Less code imported at start up is better for start up time performance
      • Unused code isn't residing in memory just because the dependency exists on disk

      AC

      • Make Snappy lazy loaded
      • Have a helper resolve or reject async based on the dependency presence
      • Update the usages of makeErrorModule and its assoc. cached variable
        • when the dependency is not present but the feature is attempted to be used users should still get a MongoMissingDependencyError
      • Add unit tests for makeErrorModule

      Test AC

      • Use unit tests to verify that importing the driver only imports expected non-lazy deps

      Follow up

      • update other dep investigation tickets with AC relating to adding lazy loading (socks, saslprep, aws4)

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Durran Jordan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: