|
| 1 | +--- |
| 2 | +id: migrate9 |
| 3 | +title: 'Migrate to version 9.0.0' |
| 4 | +--- |
| 5 | + |
| 6 | +Here are the Important changes made for 9.0.0 |
| 7 | + |
| 8 | +:::caution Important, Read this first |
| 9 | +This Guide is written for migration from version `8.16.0` to `9.0.0`, for versions `>9.0.0 <10.0.0`, please consult the [CHANGELOG](https://github.com/nodkz/mongodb-memory-server/blob/master/CHANGELOG.md) |
| 10 | +::: |
| 11 | + |
| 12 | +## Breaking Changes |
| 13 | + |
| 14 | +### Minimal NodeJS version is now `14` |
| 15 | + |
| 16 | +With 9.0.0 the minimal nodejs required is `14.20.1`. |
| 17 | + |
| 18 | +### Mongodb Driver Version upgraded to 5.x |
| 19 | + |
| 20 | +The used MongoDB Driver version is now `5.9.0`. |
| 21 | + |
| 22 | +### Default binary version is now 6.x |
| 23 | + |
| 24 | +The default binary version has been upgraded from `5.0.x` to `6.0.x`. For more specifics see [mongodb-server-versions](../mongodb-server-versions.md). |
| 25 | + |
| 26 | +### Removed platform translations |
| 27 | + |
| 28 | +Some platform translations have been removed, because they are either not needed anymore or werent properly supported in the first place: |
| 29 | + |
| 30 | +- `sunos` -> `linux` |
| 31 | +- `elementary OS` -> `linux` |
| 32 | + |
| 33 | +### Removed architectures |
| 34 | + |
| 35 | +Some architectures were removed because they were not being build by mongodb anymore and support in mongodb-memory-server has been largely untested: |
| 36 | + |
| 37 | +- `ia32` -> `i686` / `i386` |
| 38 | + |
| 39 | +### MongoMemoryServer `instance.auth` option is now ignored |
| 40 | + |
| 41 | +With 9.0.0 the option `instance.auth` option is going to be ignored, because its set via the (top-level) `auth` option directly. |
| 42 | + |
| 43 | +Example: |
| 44 | + |
| 45 | +`new MongoMemoryServer({ instance: { auth: true } })` is going to be ignored, use `new MongoMemoryServer({ auth: { enable: true } })` |
| 46 | + |
| 47 | +### `AutomaticAuth` changes |
| 48 | + |
| 49 | +`AutomaticAuth` has been changed to **not** be enabled anymore by just having a empty object. Also property `disable` has been removed and `enable` has been added. |
| 50 | + |
| 51 | +Replace `auth: {}` with `auth: { enable: true }`. |
| 52 | +Replace `auth: { disable: true }` with `auth: { enable: false }`. |
| 53 | +Replace `auth: { disable: false }` with `auth: { enable: true }`. |
| 54 | + |
| 55 | +### MongoMemoryServer and MongoReplSet `.cleanup(boolean)` and `.stop(boolean)` have been removed |
| 56 | + |
| 57 | +Previously `boolean` was the only option for the `.cleanup` and `.stop` function, but they behaved differently between those 2 function and were replaced with `Cleanup` object-options and now have been completely removed. |
| 58 | + |
| 59 | +Replace `.stop(true)` with `.stop({ doCleanup: true })`. |
| 60 | +Replace `.cleanup(true)` with `.stop({ doCleanup: true, force: true })`. |
| 61 | + |
| 62 | +Default is still for both `{ doCleanup: true, force: false }`. |
| 63 | + |
| 64 | +### `MD5_CHECK` is now enabled by default |
| 65 | + |
| 66 | +The config option [`MD5_CHECK`](../../api/config-options.md#md5_check) has been enabled by default now, resulting in always comparing the downloaded archive with a md5 after a download. |
| 67 | + |
| 68 | +### Merged Error types |
| 69 | + |
| 70 | +Some error classes have been merged: |
| 71 | + |
| 72 | +- `EnsureInstanceError` & `InstanceInfoError` -> `InstanceInfoError` |
| 73 | +- `NoSystemBinaryFoundError` & `BinaryNotFoundError` -> `BinaryNotFoundError` |
| 74 | + |
| 75 | +### Removed Storage engine `devnull` and `mmapv1` |
| 76 | + |
| 77 | +Storage Engines `devnull` and `mmapv1` have been removed because they are not supported in newer versions of mongodb anymore, `wiredTiger` should be used instead. |
| 78 | + |
| 79 | +### Linux fallback binary has been removed |
| 80 | + |
| 81 | +Previously there was a code-path for a fallback linux binary, but this has been removed because mongodb has stopped shipping generic linux binaries since versions after 4.0. |
| 82 | + |
| 83 | +If a fallback is still required, try to use the ubuntu binary via [Config Options `DISTRO`](../../api/config-options.md#distro). |
| 84 | + |
| 85 | +### Ubuntu fallback year has been updated |
| 86 | + |
| 87 | +The ubuntu fallback year has been updated to `22`, instead of the previous `14`, because newer versions of mongodb dont ship for any EOL ubuntu version anymore. |
| 88 | + |
| 89 | +This fallback is only used if the ubuntu year could not be parsed from the os-file. |
| 90 | +This can also be overwritten with [Config Option `DISTRO`](../../api/config-options.md#distro). |
| 91 | + |
| 92 | +## Non-Breaking changes / Additions |
| 93 | + |
| 94 | +### Compiler target is now `es2019` |
| 95 | + |
| 96 | +The tsconfig `target` option has been updated to `es2019`, which will result in less polyfills. |
| 97 | +This should be a non-breaking change |
| 98 | + |
| 99 | +## Crypto function have been changed to use nodejs internals |
| 100 | + |
| 101 | +Crypto functions like for the md5 check and uuidv4 generation have been moved to use the `node:crypto` support, resulting in dropping 2 dependencies. |
| 102 | + |
| 103 | +Dropped dependencies are `md5-file` and `uuid`. |
| 104 | + |
| 105 | +## Binary childprocess is now also `.unref()` |
| 106 | + |
| 107 | +The Mongodb Binary childprocess is now also `.unref()`, like the killer process has been for some time. |
| 108 | + |
| 109 | +This *should* help with non-closed instances not exiting the nodejs process. |
| 110 | + |
| 111 | +## The port testing package has been replaced |
| 112 | + |
| 113 | +Previously MMS used `get-port`, but it caused some big memory-leakage across big projects, so it has been replaced with one that uses less maps. |
| 114 | + |
| 115 | +It also has been replaced because newer versions were ESM only, but we couldnt switch to ESM yet (and using ESM in CommonJS is not a great experience) |
| 116 | + |
| 117 | +## Mongodb version 7.0.0 is now supported |
| 118 | + |
| 119 | +Mongob version `7.0.0` removed storage engine `ephemeralForTest`, with mongodb-memory-server 9.0.0 storage engine `wiredTiger` is the default for binary versions `7.0.0` and higher. |
| 120 | +Older versions (before `7.0.0`) will still continue to use `ephemeralForTest` by default. |
| 121 | + |
| 122 | +:::info |
| 123 | +The version used for the decision is the version provided via the resolved [`VERSION`](../../api/config-options.md#version) config option. |
| 124 | +This mean it needs to match the version the system binary is (a warning is printed if they are not the same). |
| 125 | + |
| 126 | +If the option is unset, the default version will be used, which is likely not correct for the system binary. |
| 127 | + |
| 128 | +If the decision should not be automatic, the storage engine can be explicitly defined as a instance option. |
| 129 | +::: |
| 130 | + |
| 131 | +It is recommended to run those instances with a db path which is equivalent to [`tmpfs`](https://wiki.archlinux.org/title/tmpfs). |
0 commit comments