[COMPASS-5401] compass-aggregations importing v8 module when used in web browser Created: 10/Jan/22  Updated: 29/Oct/23  Resolved: 17/Jan/22

Status: Closed
Project: Compass
Component/s: Aggregation pipeline
Affects Version/s: None
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: Rhys Howell Assignee: Rhys Howell
Resolution: Fixed Votes: 0
Labels: dependencies
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to COMPASS-5405 Add a web browser environment test to... Closed
Documentation Changes: Not Needed
Sprint: Iteration Seoul

 Description   

It looks like compass-aggregations imports the compass-logging package which imports mongodb-log-writer which currently assumes it’s being run in an electron environment. This ticket involves updating compass-logging to not import mongodb-log-writer when used in a browser environment.

https://github.com/mongodb-js/compass/blob/main/packages/compass-aggregations/src/modules/create-view/index.js#L1
We check if the environment is currently electron’s renderer, but not if it’s a web environment:
https://github.com/mongodb-js/compass/blob/main/packages/compass-logging/src/index.ts#L30
So we end up requiring mongodb-log-writer which has imports for file writing which would error on browser:
https://github.com/mongodb-js/mongodb-log-writer/blob/main/src/index.ts#L8

Once we've updated it to be used in the browser we should release so the dependency can be updated in cloud (mms).

Down the line we might want to add a browser environment test for compass-aggregations and other shared compass packages to protect against regressions like this.



 Comments   
Comment by Githook User [ 14/Jan/22 ]

Author:

{'name': 'Rhys', 'email': 'Anemy@users.noreply.github.com', 'username': 'Anemy'}

Message: fix(compass-logging): bump mongodb-log-writer to allow browser envs COMPASS-5401 (#2674)
Branch: COMPASS-5232-tls-tab-options
https://github.com/mongodb-js/compass/commit/1615d7e700bf0898ddd0c997ef32fdefe4bbec16

Comment by Githook User [ 13/Jan/22 ]

Author:

{'name': 'Rhys', 'email': 'Anemy@users.noreply.github.com', 'username': 'Anemy'}

Message: fix(compass-logging): bump mongodb-log-writer to allow browser envs COMPASS-5401 (#2674)
Branch: port-to-playwright
https://github.com/mongodb-js/compass/commit/1615d7e700bf0898ddd0c997ef32fdefe4bbec16

Comment by Githook User [ 12/Jan/22 ]

Author:

{'name': 'Rhys', 'email': 'Anemy@users.noreply.github.com', 'username': 'Anemy'}

Message: fix(compass-logging): bump mongodb-log-writer to allow browser envs COMPASS-5401 (#2674)
Branch: 1.30-releases
https://github.com/mongodb-js/compass/commit/1615d7e700bf0898ddd0c997ef32fdefe4bbec16

Comment by Githook User [ 11/Jan/22 ]

Author:

{'name': 'Rhys', 'email': 'Anemy@users.noreply.github.com', 'username': 'Anemy'}

Message: fix(compass-logging): bump mongodb-log-writer to allow browser envs COMPASS-5401 (#2674)
Branch: main
https://github.com/mongodb-js/compass/commit/1615d7e700bf0898ddd0c997ef32fdefe4bbec16

Generated at Wed Feb 07 22:39:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.