Skip to content

feat(workers-runtime-sdk): support embedding javascript files in sdk#90

Open
ryanking13 wants to merge 6 commits intomainfrom
gyeongjae/js-helper
Open

feat(workers-runtime-sdk): support embedding javascript files in sdk#90
ryanking13 wants to merge 6 commits intomainfrom
gyeongjae/js-helper

Conversation

@ryanking13
Copy link
Copy Markdown
Contributor

Requires cloudflare/workers-sdk#13311

This adds a JavaScript file in our Python SDK so that we can define logics in JS which cannot be implemented in Python side. I migrated patchWaitUntil function that is currently in workerd as an example.

@ryanking13 ryanking13 requested review from dom96 and hoodmane April 6, 2026 09:28
Copy link
Copy Markdown

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

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

I'm Bonk, and I've done a quick review of your PR.

This PR adds infrastructure for embedding JavaScript helper files in the Python SDK, migrating patchWaitUntil from workerd into a locally-compiled sdk.mjs.

Issues (ranked by severity)

  1. Medium: PyFuture type does not match the workerd definition — In ts/sdk.ts, PyFuture.copy() returns Promise<T> instead of PyFuture<T>. The workerd original defines type PyFuture<T> = Promise<T> & { copy(): PyFuture<T>; destroy(): void }, meaning the copy also carries destroy. While this is type-level only (esbuild strips types, and the runtime object from Pyodide is the same regardless), the type annotation is misleading for anyone reasoning about the code or adding TS tooling later. The interface should also extend Promise<T> to be accurate.

  2. Medium: Freshness test won't run in CIpackages/runtime-sdk/tests/test_js_sdk_compile.py is never executed because .github/workflows/tests.yml only runs pytest tests in packages/cli. If the .mjs drifts out of sync with the .ts source, nothing in CI will catch it.

  3. Low: esbuild version is not pinnednpx --yes esbuild uses whatever version is globally cached or latest. Different environments may produce slightly different output (e.g., whitespace changes between esbuild versions), which would cause the --check mode to report the file as out of date even when the TS source hasn't changed. Consider pinning the version, e.g., npx --yes esbuild@0.25.0.

@ask-bonk
Copy link
Copy Markdown

ask-bonk bot commented Apr 6, 2026

Review posted successfully on PR #90. Here's a summary of the feedback:

  1. Medium: PyFuture type mismatch — The PyFuture<T> interface in ts/sdk.ts doesn't match the workerd original. copy() should return PyFuture<T> (not Promise<T>), and the type should extend Promise<T>. Suggested a concrete fix using the original workerd type alias.

  2. Medium: Freshness test not covered by CI — The new test test_js_sdk_compile.py in packages/runtime-sdk/tests/ will never run because CI only executes pytest in packages/cli. The .mjs could drift without detection.

  3. Low: Unpinned esbuild versionnpx --yes esbuild without a version pin could produce different output across environments, causing spurious --check failures. Suggested pinning to a specific version.

github run

@ryanking13 ryanking13 changed the title DRAFT feat(workers-runtime-sdk): support embedding javascript files in sdk feat(workers-runtime-sdk): support embedding javascript files in sdk Apr 13, 2026
@ryanking13 ryanking13 marked this pull request as ready for review April 13, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant