Skip to content

fix(plugins): use module path for bundled jiti loads#70073

Merged
steipete merged 2 commits into
openclaw:mainfrom
yidianyiko:fix/bun-image-provider-jiti-filename
Apr 23, 2026
Merged

fix(plugins): use module path for bundled jiti loads#70073
steipete merged 2 commits into
openclaw:mainfrom
yidianyiko:fix/bun-image-provider-jiti-filename

Conversation

@yidianyiko

Copy link
Copy Markdown
Contributor

Summary

  • Problem: bundled plugin runtime loads in src/plugins/loader.ts still passed the loader module URL as jitiFilename, which keeps the Bun-installed image-provider hang from [Bug]: Bun global install hangs in openclaw infer image providers while loading bundled image providers #69783 reproducible on latest main.
  • Why it matters: openclaw infer image providers --json can hang before any image provider registers, which makes image_generate look unavailable in Bun global installs.
  • What changed: createPluginJitiLoader(...) now passes the target modulePath as jitiFilename, and a focused regression test locks that wiring in.
  • What did NOT change (scope boundary): no provider-specific code, manifests, auth logic, or fallback ordering changed.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: src/plugins/loader.ts called getCachedPluginJitiLoader(...) with jitiFilename: import.meta.url instead of the bundled plugin entry modulePath, so Jiti resolved bundled runtime loads relative to the loader module rather than the target plugin module.
  • Missing detection / guardrail: there was no regression test asserting the jitiFilename passed by createPluginJitiLoader(...) for bundled runtime loads.
  • Contributing context (if known): Bun global installs were the consistently reproducible path for the image-provider hang because that loader path was exercised while provider entrypoints themselves still imported cleanly.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/plugins/loader.jiti-filename.test.ts
  • Scenario the test should lock in: a bundled plugin runtime load should pass the target bundled module path through as jitiFilename when it asks getCachedPluginJitiLoader(...) for a loader.
  • Why this is the smallest reliable guardrail: the regression is one argument in the loader wiring; mocking getCachedPluginJitiLoader(...) isolates that contract without depending on a full Bun install.
  • Existing test that already covers this (if any): src/plugins/jiti-loader-cache.test.ts covers cache behavior once the caller passes a filename, but it did not cover the caller wiring in src/plugins/loader.ts.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Bun-installed bundled image providers now load through the plugin runtime path with the target module path as Jiti's filename base instead of the loader module URL.

Diagram (if applicable)

Before:
[bundled plugin modulePath] -> createPluginJitiLoader -> jitiFilename=loader.ts -> Jiti resolves from loader base -> bundled image provider load can hang

After:
[bundled plugin modulePath] -> createPluginJitiLoader -> jitiFilename=modulePath -> Jiti resolves from plugin base -> bundled image provider load proceeds

Security Impact (required)

  • New permissions/capabilities? (No)
  • Secrets/tokens handling changed? (No)
  • New/changed network calls? (No)
  • Command/tool execution surface changed? (No)
  • Data access scope changed? (No)
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: Ubuntu 24.04.3 LTS
  • Runtime/container: Node 22.22.0, Bun global install used for original repro
  • Model/provider: image provider discovery path (openai bundled entrypoint was the direct import control sample)
  • Integration/channel (if any): N/A
  • Relevant config (redacted): provider auth present; no extra plugin-specific config required for the regression test

Steps

  1. On latest main, run pnpm test src/plugins/loader.jiti-filename.test.ts.
  2. Observe the new test fail before the fix because jitiFilename is file:///.../src/plugins/loader.ts instead of the bundled module path.
  3. Apply the one-line loader fix and rerun the targeted plugin tests.

Expected

  • Bundled runtime loads pass the bundled module path as jitiFilename.
  • Targeted plugin loader tests pass.

Actual

  • Before the fix, the new test failed with:
    • expected: bundled module path
    • received: file:///data/projects/openclaw/src/plugins/loader.ts
  • After the fix, the targeted tests pass.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • pnpm test src/plugins/loader.jiti-filename.test.ts failed before the fix on latest main with the wrong jitiFilename.
    • pnpm test src/plugins/loader.jiti-filename.test.ts src/plugins/jiti-loader-cache.test.ts passed after the fix.
    • timeout 8s openclaw infer image providers --json still hangs in the already-installed Bun global package, confirming latest published install did not already contain this fix.
  • Edge cases checked:
    • Existing cache tests still pass via src/plugins/jiti-loader-cache.test.ts.
  • What you did not verify:
    • pnpm build is still red locally on latest main in scripts/stage-bundled-plugin-runtime-deps.mjs for unrelated discord runtime-deps staging (discord-api-types exact-version resolution).
    • The repository's staged check:changed hook is also red on latest main from unrelated tsgo:core errors in src/agents/pi-embedded-runner/compact.ts:887 and src/agents/pi-embedded-runner/run/attempt.ts:1132.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes)
  • Config/env changes? (No)
  • Migration needed? (No)
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: another loader path may intentionally rely on import.meta.url as the Jiti filename base.
    • Mitigation: the new regression test covers the bundled runtime path specifically, and the existing cache tests still pass against the unchanged cache helper behavior.

@greptile-apps

greptile-apps Bot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a one-line bug in src/plugins/loader.ts where createPluginJitiLoader was passing import.meta.url (the loader module's own URL) as the jitiFilename argument to getCachedPluginJitiLoader, instead of the target plugin's modulePath. The fix makes Jiti resolve relative imports from the plugin module's location, which unblocks bundled image-provider loads under Bun global installs. A focused regression test (loader.jiti-filename.test.ts) is added to lock in this wiring.

Confidence Score: 5/5

Safe to merge — the fix is a single correct argument substitution with a well-scoped regression test and no other touched paths.

The change is minimal and precise (one argument), the regression test properly isolates the wiring contract by mocking getCachedPluginJitiLoader, cleanup in afterEach is thorough, and no other call sites or behaviors are touched. No P0/P1 issues found.

No files require special attention.

Reviews (1): Last reviewed commit: "fix(plugins): use module path for bundle..." | Re-trigger Greptile

@prtags

prtags Bot commented Apr 23, 2026

Copy link
Copy Markdown

Related work from PRtags group heroic-newt-2cq0

Title: Open PR candidate: bundled plugin jitiFilename should use modulePath for #69783

Number Title
#70073* fix(plugins): use module path for bundled jiti loads
#70080 fix(bun): use modulePath for jitiFilename in bundled plugin loader (#69783)

* This PR

@steipete
steipete force-pushed the fix/bun-image-provider-jiti-filename branch from 1801175 to 06b7235 Compare April 23, 2026 19:09
@steipete
steipete force-pushed the fix/bun-image-provider-jiti-filename branch from 06b7235 to a94c9b2 Compare April 23, 2026 19:13
@steipete
steipete merged commit 44144cb into openclaw:main Apr 23, 2026
10 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm test src/plugins/loader.jiti-filename.test.ts src/plugins/jiti-loader-cache.test.ts; pnpm check; pnpm build
  • Source head: a94c9b2
  • Landed commits: 61e9e86, 44144cb
  • Merge commit: 44144cb

Thanks @yidianyiko!

ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request May 13, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
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.

[Bug]: Bun global install hangs in openclaw infer image providers while loading bundled image providers

2 participants