Skip to content

Commit

Permalink
fix: pre-empt linker modules with already resolved modules
Browse files Browse the repository at this point in the history
  • Loading branch information
doc-han committed Jan 14, 2025
1 parent c9afba0 commit 57bb401
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/cli/src/execute/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default async (
jobLogger: createLogger(JOB, opts),
linker: {
repo: opts.repoDir,
modules: parseAdaptors(plan),
modules: parseAdaptors(plan, opts.adaptors), // considering already resolved adaptors
},
callbacks: {
notify: async (eventName, payload) => {
Expand All @@ -49,7 +49,10 @@ export default async (
};

// TODO we should throw if the adaptor strings are invalid for any reason
export function parseAdaptors(plan: ExecutionPlan) {
export function parseAdaptors(
plan: ExecutionPlan,
resolvedAdaptors: string[] = []
) {
const extractInfo = (specifier: string) => {
const [module, path] = specifier.split('=');
const { name, version } = getNameAndVersion(module);
Expand All @@ -73,7 +76,8 @@ export function parseAdaptors(plan: ExecutionPlan) {
// But there are a couple of cases mostly in test, when validation is skipped,
// when the array may not be set
// It's mostly redundant nbut harmless to optionally chain here
job.adaptors?.forEach((adaptor) => {
const jobAdaptors = (job.adaptors || []).concat(resolvedAdaptors);
jobAdaptors.forEach((adaptor) => {
const { name, ...maybeVersionAndPath } = extractInfo(adaptor);
adaptors[name] = maybeVersionAndPath;
});
Expand Down
5 changes: 4 additions & 1 deletion packages/runtime/src/execute/step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ const executeStep = async (
plan.workflow?.credentials
);

// this ensures that already resolved modules coming from opts pre-empt the ones coming from step
const moduleInfo = { ...step.linker, ...opts.linker?.modules };

notify(NOTIFY_INIT_COMPLETE, {
jobId,
duration: Date.now() - duration,
Expand All @@ -167,7 +170,7 @@ const executeStep = async (
ctx,
job.expression,
state,
step.linker,
moduleInfo,
job.sourceMap
);
} catch (e: any) {
Expand Down

0 comments on commit 57bb401

Please sign in to comment.