Skip to content

TS SDK: minify packed bundles and find them by metadata, not filename - #73126

Merged
jason810496 merged 1 commit into
apache:mainfrom
jason810496:refactor/ts-sdk/bundle-discovery-and-minify
Sep 18, 2026
Merged

jason810496 merged 1 commit into
apache:mainfrom
jason810496:refactor/ts-sdk/bundle-discovery-and-minify

Conversation

@jason810496

@jason810496 jason810496 commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Why

  1. NodeCoordinator hard coded the bundle.mjs when discovery, so a bundles_root could hold only one bundle and its name was fixed. That defeats the Dag-to-bundle routing the embedded metadata already supports.
  2. The TS SDK artifact is not compiled with minify option, which means we have to deploy multiple *.js rather than having just one .min.js artifact.

How

  • Search each root recursively for *.min.mjs and select on metadata likeJavaCoordinator walks for *.jar and ExecutableCoordinator walks for executables. One root can now hold several bundles, and each Dag is routed to whichever bundle declares it.
  • Minify the esbuild output. A digest over the code region is only worth taking when the artifact is not something
    anyone reads or edits in place, which is what .min records.
  • airflow-ts-pack gains --outfile, rejecting it alongside --outdir and rejecting a name the coordinator could
    never find.

The bundle container format is unchanged. Minification only changes which bytes land inside the already-digested code region.


Was generative AI tooling used to co-author this PR?

@boring-cyborg boring-cyborg Bot added area:coordinator Coordinator: The interface to spawn Lang-SDK subprocesses area:e2e-tests area:task-sdk area:ts-sdk kind:documentation labels Sep 14, 2026
@jason810496
jason810496 marked this pull request as draft September 15, 2026 02:20
@jason810496
jason810496 force-pushed the refactor/ts-sdk/bundle-discovery-and-minify branch 2 times, most recently from 3d54b56 to df24628 Compare September 17, 2026 05:22
@jason810496 jason810496 self-assigned this Sep 17, 2026
@jason810496
jason810496 marked this pull request as ready for review September 17, 2026 05:23

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks one feedback regarding "keepNames"

Comment thread ts-sdk/src/cli/pack.ts Resolved
@jason810496
jason810496 marked this pull request as draft September 18, 2026 01:45
NodeCoordinator looked for exactly `bundle.mjs` in each configured root, so a
`bundles_root` could hold only one bundle and its name was fixed. That defeats
the Dag-to-bundle routing the embedded metadata already supports, and it is out
of step with JavaCoordinator and ExecutableCoordinator, which walk their roots
and select on metadata. Each root is now searched recursively for `*.min.mjs`
bundles, so one directory can hold several and each Dag is routed to whichever
bundle declares it. Roots are searched in configured order and each directory
in sorted path order, so which bundle wins no longer depends on the order a
filesystem returns entries in. `airflow-ts-pack` gains `--outfile` for naming
the artifact.

esbuild output is also minified now. An integrity digest over the code region
is only worth taking when the artifact is not something anyone is expected to
read or edit in place, which is what `.min` records. Dependencies' license
banners are preserved. Identifier names are not: nothing identifies a Dag, a
task, or a handler by a function name, so there is nothing for minification to
break, and ADR-0002 already settled that a bundle-wide `keepNames` is not how
a name reaches the registration that needs it.

The bundle container format is unchanged; minification only changes which bytes
land inside the already-digested code region.
@jason810496
jason810496 force-pushed the refactor/ts-sdk/bundle-discovery-and-minify branch from df24628 to 3c76d37 Compare September 18, 2026 03:45
@jason810496
jason810496 marked this pull request as ready for review September 18, 2026 08:35

@pierrejeambrun pierrejeambrun left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in the latest commit, thanks.

I don't see the 'onLoad' here, do you plan on adding

In the case of mixed language TaskHandler, since user need to explicitly mention task_id (new TaskHandler(dagId, taskId, handler)), so it's fine to minify without keeping the function name.

taskid remains 'optional' for mixed dag as documented here #73126.

task_id is optional but should probably be written out here.** Most of the time because of
naming convention difference between python and typescript, names won't match. Omitting it defaults
the id to the handler's function name — new TaskHandler(transformStep) binds the "transformStep" fn to the
"transformStep" task. On the other hand new TaskHandler("transform_step", transformStep) will bind to
"transform_step" task.

Should we add the onLoad in this PR or did you plan to add it later? (Did I get it wrong and you want to keep 'taskId' required for mixed dag? I thought about it when drafting #73126 but didn't want to enforce that. Mostly for consistency with the native dag and also because that's probably the expected behavior, especially if those are double checked at parse time, it won't be too bad if there is a mismatch. Many 'single word' task ID will still match and can rely on this feature 'transform', 'extract', 'load', etc.).

@jason810496 jason810496 left a comment •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omitting it defaults
the id to the handler's function name — new TaskHandler(transformStep) binds the "transformStep" fn to the
"transformStep" task. On the other hand new TaskHandler("transform_step", transformStep) will bind to
"transform_step" task.

I overlooked this part in previous review. The signature should be new TaskHandler(mandatory dag_id, optional task_id, fn), the ADR recorded it incorrect (missing the dag_id from the signature).

I'd like to have a follow-up PR that fixes the statement, make the task_id in TaskHandler optional and add the onLoad hook in the packing stage.

@jason810496

jason810496 commented Sep 18, 2026 •

Copy link
Copy Markdown
Member Author

Actually in the case of Go SDK:

  • For TaskHandler interface, we keep the dag_id and task_id as mandatory
  • For native Dag, the task_id can be optional.

How about let's follow the same convention as Go SDK side as well on TS SDK?
That the dag_id and task_id are mandatory for TaskHandler.

Since whether to omit the task_id makes more sense in the native Dag feature.

@pierrejeambrun

Copy link
Copy Markdown
Member

Ok let's do that, let me update the ts ADR

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jason810496
jason810496 merged commit f3faf90 into apache:main Sep 18, 2026
210 of 213 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants