Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/plain-taxis-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@openfn/runtime': minor
---

- Enable full compatibility with node 24
- When loading modules, prefer ESM targets over CJS targets
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
docker:
- image: cimg/node:22.20
- image: cimg/node:24.14
resource_class: medium
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:

build:
docker:
- image: cimg/node:22.20
- image: cimg/node:24.14
resource_class: medium
steps:
- attach_workspace:
Expand All @@ -50,7 +50,7 @@ jobs:

unit_test:
docker:
- image: cimg/node:22.20
- image: cimg/node:24.14
resource_class: medium
parallelism: 1
steps:
Expand All @@ -62,7 +62,7 @@ jobs:

format:
docker:
- image: cimg/node:22.20
- image: cimg/node:24.14
resource_class: medium
steps:
- attach_workspace:
Expand All @@ -73,7 +73,7 @@ jobs:

type_check:
docker:
- image: cimg/node:22.20
- image: cimg/node:24.14
resource_class: medium
steps:
- attach_workspace:
Expand Down Expand Up @@ -131,6 +131,6 @@ workflows:
- integration_test:
matrix:
parameters:
node_version: ['22.20']
node_version: ['22.20', '24.14.0']
requires:
- build
8 changes: 4 additions & 4 deletions .github/workflows/project-integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.label.name == 'run_project_tests'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v6
- name: Checkout Integration Test Repo
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
repository: openfn/project-integration-tests
path: resources/repo
- uses: actions/setup-node@v3
- uses: actions/setup-node@v6
with:
node-version: '22.12'
node-version: '24.14'
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm install:openfnx
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
fetch-depth: 1
- uses: actions/setup-node@v6
with:
node-version: '22.12'
node-version: '24.14'
- uses: pnpm/action-setup@v4
- run: pnpm install
- run: pnpm build
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 22.12.0
nodejs 24.14.0
2 changes: 1 addition & 1 deletion integration-tests/cli/modules/test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@openfn/language-test",
"version": "0.0.1",
"type": "module",
"module": "index.js",
"main": "index.js",
"private": true,
"devDependencies": {}
}
17 changes: 14 additions & 3 deletions integration-tests/cli/test/autoinstall.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,22 @@ test.serial(
}
);

/***
* Important: these tests are skipped because the old @openfn/language-testing package,
* which has been deprecated and removed from adaptors repo, depends on a version of
* language-common which just happens to be incompatible with node24
*
* Since the pre-release stuff is sitting unreleased these tests will just sit on skipped
* We should work out how to build a new version of this package (not in the adaptors repo)
* And probably remove the common dependency
*/

// Ignore the @next version if present but we asked for latest
test.serial(
test.serial.skip(
`openfn ${jobsPath}/simple.js -a testing@latest ${repoDir} ${log}`,
async (t) => {
const { stdout, err } = await run(t.title);
console.log(stdout);

// t.falsy(err); // TODO I think this is a broken adaptor build?
t.regex(stdout, /Auto-installing language adaptors/);
Expand All @@ -109,7 +120,7 @@ test.serial(
);

// Ignore @next if present but we asked for no version
test.serial(
test.serial.skip(
`openfn ${jobsPath}/simple.js -a testing ${repoDir} ${log}`,
async (t) => {
const { stdout, err } = await run(t.title);
Expand All @@ -126,7 +137,7 @@ test.serial(

// TODO we need to fix the version of testing
// maybe after release we can push next onto 2.0 and leave latest on 1.0
test.serial(
test.serial.skip(
`openfn ${jobsPath}/simple.js -a testing@next ${repoDir} ${log}`,
async (t) => {
const { stdout, stderr } = await run(t.title);
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/cli/test/deploy.v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ test.serial('pull a project', async (t) => {
t.regex(yaml, /id\: test-project/);
});

test.serial.only('pull, change and re-deploy', async (t) => {
test.serial('pull, change and re-deploy', async (t) => {
const projectId = 'aaaaaaaa';
server.addProject(makeProject(projectId) as any);

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/cli/test/errors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ test.serial('job with reference error', async (t) => {
'ref aborted with error (SSSms)',
`TypeError: Cannot read properties of undefined (reading 'y')
at vm:module(0):1:23
@openfn/language-common_2.1.1/dist/index.cjs:333:12`,
@openfn/language-common_2.1.1/dist/index.js:270:12`,
'Error occurred at: ref',
'1: fn((state) => state.x.y)',
' ^ ',
Expand All @@ -178,7 +178,7 @@ test.serial('job with not a function error', async (t) => {
'not-function aborted with error (SSSms)',
`TypeError: state is not a function
at vm:module(0):1:15
@openfn/language-common_2.1.1/dist/index.cjs:333:12`,
@openfn/language-common_2.1.1/dist/index.js:270:12`,
'Error occurred at: not-function',
'1: fn((state) => state())',
' ^ ',
Expand All @@ -198,7 +198,7 @@ test.serial('job with assign-to-const error', async (t) => {
'assign-const aborted with error (SSSms)',
`TypeError: Assignment to constant variable.
at vm:module(0):1:33
@openfn/language-common_2.1.1/dist/index.cjs:333:12`,
@openfn/language-common_2.1.1/dist/index.js:270:12`,
'Error occurred at: assign-const',
'1: fn((state) => { const x = 10; x = 20; })',
' ^ ',
Expand Down
1 change: 1 addition & 0 deletions integration-tests/worker/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 24.14.0
17 changes: 11 additions & 6 deletions integration-tests/worker/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ import createLightningServer, { toBase64 } from '@openfn/lightning-mock';
import createEngine from '@openfn/engine-multi';
import createWorkerServer from '@openfn/ws-worker';
import { createMockLogger } from '@openfn/logger';
// import createLogger from '@openfn/logger';
import createLogger from '@openfn/logger';

const debugWorker = process.env.OPENFN_DEBUG_WORKER;
const debugLightning = process.env.OPENFN_DEBUG_LIGHTNING;

export const randomPort = () => Math.round(2000 + Math.random() * 1000);

export const initLightning = (port = 4000, privateKey?: string) => {
// TODO the lightning mock right now doesn't use the secret
// but we may want to add tests against this
const opts = { port };
const opts: any = { port };
if (privateKey) {
// @ts-ignore
opts.runPrivateKey = toBase64(privateKey);
}
// opts.logger = createLogger('LTG', { level: 'debug' });
if (debugLightning) {
opts.logger = createLogger('LTG', { level: 'debug' });
}
return createLightningServer(opts);
};

Expand All @@ -40,8 +44,9 @@ export const initWorker = async (
});

const worker = createWorkerServer(engine, {
logger: createMockLogger(),
// logger: createLogger('worker', { level: 'debug' }),
logger: debugWorker
? createLogger('worker', { level: 'debug' })
: createMockLogger(),
port: workerPort,
lightning: `ws://localhost:${lightningPort}/worker`,
secret: crypto.randomUUID(),
Expand Down
38 changes: 1 addition & 37 deletions integration-tests/worker/test/runs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ test.serial('run parallel jobs', async (t) => {

test.serial('run a http adaptor job', async (t) => {
const job = createJob({
adaptor: '@openfn/language-http@7.2.0',
adaptor: '@openfn/language-http@7.2.9',
body: `get("https://jsonplaceholder.typicode.com/todos/1");
fn((state) => { state.res = state.response; return state });`,
});
Expand All @@ -217,40 +217,6 @@ test.serial('run a http adaptor job', async (t) => {
});
});

test.serial('use different versions of the same adaptor', async (t) => {
// http@5 exported an axios global - so run this job and validate that the global is there
const job1 = createJob({
body: `import { axios } from "@openfn/language-http";
fn((s) => {
if (!axios) {
throw new Error('AXIOS NOT FOUND')
}
return s;
})`,
adaptor: '@openfn/language-http@5.0.4',
});

// http@6 no longer exports axios - so throw an error if we see it
const job2 = createJob({
body: `import { axios } from "@openfn/language-http";
fn((s) => {
if (axios) {
throw new Error('AXIOS FOUND')
}
return s;
})`,
adaptor: '@openfn/language-http@6.0.0',
});

// Just for fun, run each job a couple of times to make sure that there's no wierd caching or ordering anything
const steps = [job1, job2, job1, job2];
const attempt = createRun([], steps, []);

const result = await run(t, attempt);
t.log(result);
t.falsy(result.errors);
});

test.serial('Run with collections', async (t) => {
const job1 = createJob({
body: `fn((state = {}) => {
Expand All @@ -270,8 +236,6 @@ test.serial('Run with collections', async (t) => {
state.results.push({ key, value })
});
`,
// Note: for some reason 1.7.0 fails because it exports a collections ??
// 1.7.4 seems fine
adaptor: '@openfn/language-common@1.7.4',
});
const attempt = createRun([], [job1], []);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
"tar-stream": "^3.1.8",
"typesync": "^0.14.3"
},
"packageManager": "pnpm@10.17.1+sha512.17c560fca4867ae9473a3899ad84a88334914f379be46d455cbf92e5cf4b39d34985d452d2583baf19967fa76cb5c17bc9e245529d0b98745721aa7200ecaf7a"
"packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be"
}
5 changes: 4 additions & 1 deletion packages/cli/src/metadata/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Logger } from '../util/logger';
import { MetadataOpts } from './command';
import loadState from '../util/load-state';
import * as cache from './cache';
import { getModuleEntryPoint } from '@openfn/runtime';
import { getModuleEntryPoint, registerEsmHook } from '@openfn/runtime';
import { ExecutionPlan } from '@openfn/lexicon';
import { install, removePackage } from '../repo/handler';

Expand Down Expand Up @@ -68,6 +68,9 @@ const metadataHandler = async (
process.exit(1);
}

// This is needed to import older packages which aren't fully ESM compatible
registerEsmHook();

const state = await loadState({} as ExecutionPlan, options, logger);
logger.success(`Generating metadata`);

Expand Down
5 changes: 3 additions & 2 deletions packages/cli/src/projects/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path';
import { mkdir, writeFile } from 'node:fs/promises';
import { Provisioner } from '@openfn/lexicon/lightning';
import { fetch } from 'undici';

import type { Opts } from '../options';
import type { Logger } from '@openfn/logger';
Expand Down Expand Up @@ -143,7 +144,7 @@ export async function fetchProject(
);
}
logger?.info(`Project retrieved from ${endpoint}`);
return response.json();
return response.json() as any;
} catch (error: any) {
handleCommonErrors({ endpoint, apiKey }, error);

Expand Down Expand Up @@ -188,7 +189,7 @@ export async function deployProject(
);
}

return await response.json();
return (await response.json()) as any;
} catch (error: any) {
handleCommonErrors({ endpoint, apiKey }, error);

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/test/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const testHandler = async (options: TestOptions, logger: Logger) => {
{
id: 'calculate',
expression:
"const fn = () => (state) => { console.log('Calculating to life, the universe, and everything..'); return state }; fn()",
"const fn = () => (state) => { console.log('Calculating life, the universe, and everything...'); return state }; fn()",
next: {
result: true,
},
Expand Down
Loading