From 5447c222c8e2460c1edd47cc8e3bea4d4b43abed Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 12 Jan 2025 12:10:35 +1100 Subject: [PATCH] fix: Push adapter not loading on some versions of Node 22 (#9525) --- .github/workflows/ci.yml | 34 +++++++++++++++++----------------- src/Adapters/AdapterLoader.js | 16 ++-------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6ea18c7244..b8fcbb4b86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,7 @@ on: paths-ignore: - '**/**.md' env: - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 PARSE_SERVER_TEST_TIMEOUT: 20000 permissions: actions: write @@ -145,32 +145,32 @@ jobs: - name: MongoDB 4.2, ReplicaSet MONGODB_VERSION: 4.2.25 MONGODB_TOPOLOGY: replset - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: MongoDB 4.4, ReplicaSet MONGODB_VERSION: 4.4.29 MONGODB_TOPOLOGY: replset - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: MongoDB 5, ReplicaSet MONGODB_VERSION: 5.0.26 MONGODB_TOPOLOGY: replset - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: MongoDB 6, ReplicaSet MONGODB_VERSION: 6.0.14 MONGODB_TOPOLOGY: replset - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: MongoDB 7, ReplicaSet MONGODB_VERSION: 7.0.8 MONGODB_TOPOLOGY: replset - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: MongoDB 8, ReplicaSet MONGODB_VERSION: 8.0.0 MONGODB_TOPOLOGY: replset - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: Redis Cache PARSE_SERVER_TEST_CACHE: redis MONGODB_VERSION: 8.0.0 MONGODB_TOPOLOGY: standalone - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: Node 20 MONGODB_VERSION: 8.0.0 MONGODB_TOPOLOGY: standalone @@ -227,31 +227,31 @@ jobs: include: - name: PostgreSQL 13, PostGIS 3.1 POSTGRES_IMAGE: postgis/postgis:13-3.1 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 13, PostGIS 3.2 POSTGRES_IMAGE: postgis/postgis:13-3.2 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 13, PostGIS 3.3 POSTGRES_IMAGE: postgis/postgis:13-3.3 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 13, PostGIS 3.4 POSTGRES_IMAGE: postgis/postgis:13-3.4 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 13, PostGIS 3.5 POSTGRES_IMAGE: postgis/postgis:13-3.5 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 14, PostGIS 3.5 POSTGRES_IMAGE: postgis/postgis:14-3.5 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 15, PostGIS 3.5 POSTGRES_IMAGE: postgis/postgis:15-3.5 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 16, PostGIS 3.5 POSTGRES_IMAGE: postgis/postgis:16-3.5 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 - name: PostgreSQL 17, PostGIS 3.5 POSTGRES_IMAGE: postgis/postgis:17-3.5 - NODE_VERSION: 22.4.1 + NODE_VERSION: 22.12.0 fail-fast: false name: ${{ matrix.name }} timeout-minutes: 20 diff --git a/src/Adapters/AdapterLoader.js b/src/Adapters/AdapterLoader.js index 5d9d9b0332..aa40162cd0 100644 --- a/src/Adapters/AdapterLoader.js +++ b/src/Adapters/AdapterLoader.js @@ -47,20 +47,8 @@ export function loadAdapter(adapter, defaultAdapter, options): T { } export async function loadModule(modulePath) { - let module; - try { - module = require(modulePath); - } catch (err) { - if (err.code === 'ERR_REQUIRE_ESM') { - module = await import(modulePath); - if (module.default) { - module = module.default; - } - } else { - throw err; - } - } - return module; + const module = await import(modulePath); + return module?.default || module; } export default loadAdapter;