Skip to content

Commit 5447c22

Browse files
authored
fix: Push adapter not loading on some versions of Node 22 (#9525)
1 parent 4ac8aef commit 5447c22

File tree

2 files changed

+19
-31
lines changed

2 files changed

+19
-31
lines changed

.github/workflows/ci.yml

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
paths-ignore:
99
- '**/**.md'
1010
env:
11-
NODE_VERSION: 22.4.1
11+
NODE_VERSION: 22.12.0
1212
PARSE_SERVER_TEST_TIMEOUT: 20000
1313
permissions:
1414
actions: write
@@ -145,32 +145,32 @@ jobs:
145145
- name: MongoDB 4.2, ReplicaSet
146146
MONGODB_VERSION: 4.2.25
147147
MONGODB_TOPOLOGY: replset
148-
NODE_VERSION: 22.4.1
148+
NODE_VERSION: 22.12.0
149149
- name: MongoDB 4.4, ReplicaSet
150150
MONGODB_VERSION: 4.4.29
151151
MONGODB_TOPOLOGY: replset
152-
NODE_VERSION: 22.4.1
152+
NODE_VERSION: 22.12.0
153153
- name: MongoDB 5, ReplicaSet
154154
MONGODB_VERSION: 5.0.26
155155
MONGODB_TOPOLOGY: replset
156-
NODE_VERSION: 22.4.1
156+
NODE_VERSION: 22.12.0
157157
- name: MongoDB 6, ReplicaSet
158158
MONGODB_VERSION: 6.0.14
159159
MONGODB_TOPOLOGY: replset
160-
NODE_VERSION: 22.4.1
160+
NODE_VERSION: 22.12.0
161161
- name: MongoDB 7, ReplicaSet
162162
MONGODB_VERSION: 7.0.8
163163
MONGODB_TOPOLOGY: replset
164-
NODE_VERSION: 22.4.1
164+
NODE_VERSION: 22.12.0
165165
- name: MongoDB 8, ReplicaSet
166166
MONGODB_VERSION: 8.0.0
167167
MONGODB_TOPOLOGY: replset
168-
NODE_VERSION: 22.4.1
168+
NODE_VERSION: 22.12.0
169169
- name: Redis Cache
170170
PARSE_SERVER_TEST_CACHE: redis
171171
MONGODB_VERSION: 8.0.0
172172
MONGODB_TOPOLOGY: standalone
173-
NODE_VERSION: 22.4.1
173+
NODE_VERSION: 22.12.0
174174
- name: Node 20
175175
MONGODB_VERSION: 8.0.0
176176
MONGODB_TOPOLOGY: standalone
@@ -227,31 +227,31 @@ jobs:
227227
include:
228228
- name: PostgreSQL 13, PostGIS 3.1
229229
POSTGRES_IMAGE: postgis/postgis:13-3.1
230-
NODE_VERSION: 22.4.1
230+
NODE_VERSION: 22.12.0
231231
- name: PostgreSQL 13, PostGIS 3.2
232232
POSTGRES_IMAGE: postgis/postgis:13-3.2
233-
NODE_VERSION: 22.4.1
233+
NODE_VERSION: 22.12.0
234234
- name: PostgreSQL 13, PostGIS 3.3
235235
POSTGRES_IMAGE: postgis/postgis:13-3.3
236-
NODE_VERSION: 22.4.1
236+
NODE_VERSION: 22.12.0
237237
- name: PostgreSQL 13, PostGIS 3.4
238238
POSTGRES_IMAGE: postgis/postgis:13-3.4
239-
NODE_VERSION: 22.4.1
239+
NODE_VERSION: 22.12.0
240240
- name: PostgreSQL 13, PostGIS 3.5
241241
POSTGRES_IMAGE: postgis/postgis:13-3.5
242-
NODE_VERSION: 22.4.1
242+
NODE_VERSION: 22.12.0
243243
- name: PostgreSQL 14, PostGIS 3.5
244244
POSTGRES_IMAGE: postgis/postgis:14-3.5
245-
NODE_VERSION: 22.4.1
245+
NODE_VERSION: 22.12.0
246246
- name: PostgreSQL 15, PostGIS 3.5
247247
POSTGRES_IMAGE: postgis/postgis:15-3.5
248-
NODE_VERSION: 22.4.1
248+
NODE_VERSION: 22.12.0
249249
- name: PostgreSQL 16, PostGIS 3.5
250250
POSTGRES_IMAGE: postgis/postgis:16-3.5
251-
NODE_VERSION: 22.4.1
251+
NODE_VERSION: 22.12.0
252252
- name: PostgreSQL 17, PostGIS 3.5
253253
POSTGRES_IMAGE: postgis/postgis:17-3.5
254-
NODE_VERSION: 22.4.1
254+
NODE_VERSION: 22.12.0
255255
fail-fast: false
256256
name: ${{ matrix.name }}
257257
timeout-minutes: 20

src/Adapters/AdapterLoader.js

+2-14
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,8 @@ export function loadAdapter<T>(adapter, defaultAdapter, options): T {
4747
}
4848

4949
export async function loadModule(modulePath) {
50-
let module;
51-
try {
52-
module = require(modulePath);
53-
} catch (err) {
54-
if (err.code === 'ERR_REQUIRE_ESM') {
55-
module = await import(modulePath);
56-
if (module.default) {
57-
module = module.default;
58-
}
59-
} else {
60-
throw err;
61-
}
62-
}
63-
return module;
50+
const module = await import(modulePath);
51+
return module?.default || module;
6452
}
6553

6654
export default loadAdapter;

0 commit comments

Comments
 (0)