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

fix(NODE-4425): webpack optional import of FLE issue #3324

Merged
merged 4 commits into from Jul 19, 2022

Conversation

nbbeeken
Copy link
Contributor

Description

What is changing?

Move FLE require back into a try catch block.

What is the motivation for this change?

Webpack needs optional requires to be inside of a try catch.

Double check the following

  • Ran npm run check:lint script
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: <type>(NODE-xxxx)<!>: <description>
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@nbbeeken nbbeeken marked this pull request as ready for review July 18, 2022 19:09
@nbbeeken nbbeeken changed the title fix(NODE-4425): webpack optional import issue fix(NODE-4425): webpack optional import of FLE issue Jul 18, 2022
Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add a test for fle to optional_require.test.js?

@dariakp dariakp added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 18, 2022
@nbbeeken
Copy link
Contributor Author

Should we add a test for fle to optional_require.test.js?

From slack, decided to follow up with this: https://jira.mongodb.org/browse/NODE-4442

@dariakp dariakp added Team Review Needs review from team and removed Primary Review In Review with primary reviewer, not yet ready for team's eyes labels Jul 18, 2022
dariakp
dariakp previously approved these changes Jul 18, 2022
src/utils.ts Outdated

// NOTE(NODE-4254): This is to get around the circular dependency between
// mongodb-client-encryption and the driver in the test scenarios.
if (
typeof process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE === 'string' &&
process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE.length > 0
) {
mongodbClientEncryption = require(process.env.MONGODB_CLIENT_ENCRYPTION_OVERRIDE);
try {
// NOTE(NODE-3199): Ensure you always wrap an optional require in the try block
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As someone who read this comment and didn't realize that the require must literally be inside the try catch, can we update the comment to be more descriptive?

Copy link
Contributor

@dariakp dariakp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to address lint failures

@dariakp dariakp merged commit 5ab2b05 into main Jul 19, 2022
@dariakp dariakp deleted the NODE-4425/webpack-fix branch July 19, 2022 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Team Review Needs review from team
Projects
None yet
3 participants