Skip to content

Local execution passes an unresolved imports Promise #1358

Description

@MicroMilo

Summary

The local-execution worker passes the Promise returned by async getProgramImports as if it were a resolved ProgramImports object. ProgramManager treats the truthy Promise as caller-provided imports, spreads no program entries from it, and suppresses its own fallback fetch.

Impact: Website local execution works for import-free programs but passes an empty import set for programs with imports, causing imported calls to fail during ProgramManager.run.

Code path

Checked against current mainnet at commit 543b41e0a7e3d6a8a49ae8d0870809dc92b88684.

  • website/src/workers/worker.js:33-52
  • sdk/src/program-manager.ts:403-424
  • website/src/tabs/develop/execute/index.jsx:85-92

Steps to reproduce

Validation level: current HEAD supplemental dynamic witness reproduced.

node -e '(async()=>{const importNames=["dep.aleo"]; const imports=Promise.resolve({"dep.aleo":"program dep.aleo;"}); let resolvedImports={}; if(imports) resolvedImports={...imports}; if(importNames.length>0&&!imports) resolvedImports=await imports; console.log(JSON.stringify({isPromise:imports instanceof Promise,resolved:Object.keys(resolvedImports)}));})()'

Observed output:

{"isPromise":true,"resolved":[]}

Neighboring control:

node -e '(async()=>{const importNames=["dep.aleo"]; const imports=await Promise.resolve({"dep.aleo":"program dep.aleo;"}); let resolvedImports={}; if(imports) resolvedImports={...imports}; if(importNames.length>0&&!imports) resolvedImports=await imports; console.log(JSON.stringify({isPromise:imports instanceof Promise,resolved:Object.keys(resolvedImports)}));})()'

Control output:

{"isPromise":false,"resolved":["dep.aleo"]}

Expected behavior

The documented/source-grounded contract should hold without the drift described above.

Actual behavior

Local execution passes a Promise where ProgramImports is expected, producing an empty import set and suppressing fallback resolution.

Existing coverage

I checked the current issue and PR lists for overlapping titles/root-cause keywords before filing this. I did not find an item covering this same root cause.

Suggested fix

Await getProgramImports before passing the imports object to ProgramManager.run.

Suggested tests

  • Add a regression test for the reproduction above.
  • Add a neighboring control assertion so the intended non-bug path remains covered.

Submitted with Codex.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions