Skip to content

Make Node V1 APIs idiomatic - #1398

Merged
Branden Bonaby (bbonaby) merged 1 commit into
mainfrom
user/bbonaby/update-node-apis
Oct 5, 2026
Merged

Branden Bonaby (bbonaby) merged 1 commit into
mainfrom
user/bbonaby/update-node-apis

Conversation

@bbonaby

@bbonaby Branden Bonaby (bbonaby) commented Oct 5, 2026 •

Copy link
Copy Markdown
Collaborator

📖 Description

  • Make asynchronous Node V1 APIs use plain verb names and return Promises.
  • Remove duplicate blocking and *Async execution APIs; rename MxcProcess.waitAsync() to wait().
  • Update telemetry consent names, tests, examples, and versioned references.

🔗 References

None.

🔍 Validation

  • npm run typecheck — passed, including the packed integration build.
  • Targeted changed unit tests — passed.
  • npm test — one unrelated environment-specific probe test failed because the local native library does not export mxc_probe_request_json_with_error.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task

GitHub Actions runs the PR validation build automatically. The ADO pipeline
(MXC-PR-Build) is the Azure version of the PR pipeline, kept in parity with the GitHub
Actions build; it runs on merge to main, and Microsoft reviewers with write access can trigger it
on a PR with /azp run. See docs/pull-requests.md.

If the dependency-feed-check check fails on a new dependency, the crate must be added to
the feed before the PR can pass. See docs/pull-requests.md
for the steps.

Microsoft Reviewers: Open in CodeFlow

Use Promise-returning plain-verb names for asynchronous execution, process waiting, and telemetry consent APIs, and update tests and documentation.

Co-authored-by: Copilot <[email protected]>
@bbonaby
Branden Bonaby (bbonaby) requested a review from a team as a code owner October 5, 2026 21:40
Copilot AI balanced review requested due to automatic review settings October 5, 2026 21:40
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

get warnings(): readonly string[];
get outputMetadata(): ExecutionMetadata | undefined;
waitAsync(): Promise<WaitResult>;
wait(): Promise<WaitResult>;

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.

wait

await wait() is that idiomatic?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

which part? you mean having to await the function? or it not having Async at the end of the name? Looking at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function as a reference I don't see them adding async to the names

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.

sry, i meant the first part - awaiting a fucntion specically called wait().

i thought it should be awaiting a function called join or something

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Refactors the Node V1 SDK surface to be more idiomatic by making previously “sync vs async” split APIs consistently Promise-based, renaming *Async APIs to plain verbs, and updating the surrounding tests/docs accordingly.

Changes:

  • Removed duplicate “blocking” and *Async variants; primary operations like run, spawn, runInContainer, spawnInContainer now return Promises.
  • Renamed MxcProcess.waitAsync() to wait(), and updated usage across unit/integration tests.
  • Renamed telemetry consent APIs to non-*Async names and updated docs/references.
File Description
sdk/​node/​tests/​unit/​telemetry.test.ts Updates tests to use renamed telemetry consent APIs.
sdk/​node/​tests/​unit/​state-aware.test.ts Migrates lifecycle tests to Promise-based runInContainer/spawnInContainer and wait().
sdk/​node/​tests/​unit/​state-aware-types.test.ts Updates type-level tests for Promise-based runInContainer.
sdk/​node/​tests/​unit/​sandbox-process.test.ts Renames waitAsync() usage to wait() in process tests.
sdk/​node/​tests/​unit/​inprocess-run.test.ts Updates one-shot run/spawn tests to Promise-only APIs and validates removed exports.
sdk/​node/​tests/​integration/​wslc-state-aware.test.ts Updates WSLC lifecycle E2E tests to Promise-based APIs and wait().
sdk/​node/​tests/​integration/​wslc-e2e.test.ts Updates WSLC one-shot E2E tests to run()/spawn() Promise APIs.
sdk/​node/​tests/​integration/​windows-process-container.test.ts Removes runAsync/spawnAsync coverage and updates wait() calls.
sdk/​node/​tests/​integration/​test-helpers.ts Switches helper to call run() instead of runAsync().
sdk/​node/​tests/​integration/​native-streaming.test.ts Renames internal streaming interface method to wait().
sdk/​node/​tests/​integration/​macos-seatbelt.test.ts Updates to awaited spawn() and wait().
sdk/​node/​tests/​integration/​linux-bubblewrap.test.ts Updates commentary to refer to run routing.
sdk/​node/​tests/​integration/​isolation-session-state-aware.test.ts Migrates tests to async runInContainer/spawnInContainer and wait().
sdk/​node/​tests/​integration/​common.test.ts Collapses dry-run rejection tests to Promise-based operations.
sdk/​node/​src/​v1/​telemetry.ts Renames exported telemetry consent functions to non-*Async names.
sdk/​node/​src/​v1/​operation-options.ts Updates option doc comments to reflect removed *Async APIs.
sdk/​node/​src/​v1/​lifecycle.ts Makes state-aware spawnInContainer*/runInContainer* Promise-only; removes sync path.
sdk/​node/​src/​v1/​index.ts Updates V1 exports to remove *Async and export renamed telemetry APIs.
sdk/​node/​src/​v1/​container.ts Makes run/spawn Promise-only and removes sync implementations.
sdk/​node/​src/​v1/​container-process.ts Renames waitAsync() to wait() and updates related messaging.
sdk/​node/​src/​index.ts Updates top-level example to use run() Promise API.
sdk/​node/​README.md Updates README examples and API descriptions for Promise-only APIs and wait().
sdk/​node/​CHANGELOG.md Updates changelog bullets to reflect new Promise-only API surface.
docs/​wsl/​wsl-container-getting-started.md Updates docs example to use awaited spawn() and wait().
docs/​state-aware-lifecycle/​mxc-state-aware-sandbox-api.md Updates API tables/examples to Promise-only Node APIs.
docs/​state-aware-lifecycle/​mxc-state-aware-sandbox-api-overview.md Updates capability matrix for Node Promise-only APIs.
docs/​reference/​node/​v1/​types.md Updates reference types for wait() and updated comments.
docs/​reference/​node/​v1/​api.md Updates API reference entries to Promise-only and renamed telemetry functions.
docs/​lxc-support/​lxc-backend.md Updates wait call naming in LXC docs example.
docs/​isolation-session/​state-aware-typescript.md Updates lifecycle TypeScript docs for Promise-only APIs.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 215 to 221
const child = spawn(request);
child.standardOutput?.on('data', (data) => process.stdout.write(data));
try {
const outcome = await child.waitAsync();
const outcome = await child.wait();
console.log('Exit:', outcome.exitCode);
} finally {
child.dispose();
const result = runInContainer(isolation, { command: 'echo' });
const exitCode: number = result.exitCode;
const exitCode: number = (await result).exitCode;
runInContainer(wslc, { command: 'echo', network: {} });

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.

:shipit:

@bbonaby
Branden Bonaby (bbonaby) merged commit ed97ee6 into main Oct 5, 2026
72 of 74 checks passed
@bbonaby
Branden Bonaby (bbonaby) deleted the user/bbonaby/update-node-apis branch October 5, 2026 23:14
Chaz Gordish (ChazGo) pushed a commit to ChazGo/mxc that referenced this pull request Oct 7, 2026
Bring the prototype onto the MXC 1.0 SDKs: the consolidated mxc-sdk crate
(microsoft#1390), the v1 ContainerRequest surfaces in Rust, Node and .NET, exact
JSON FFI ingress, and Promise-based Node v1 APIs (microsoft#1398).

Shared files take upstream as-is. The previous SDK wiring (mxc-sdk
re-exports, mxc_ffi exports, Node and .NET wrappers, and their tests)
targeted the retired SandboxPolicy surfaces and is removed here; the
following commits port the store into mxc-sdk's internal policy_store
module and rebuild the bindings on the v1 requirements API from spec
f7a450c. The catalog crate under src/core/mxc_policy_store is left
outside the workspace until that port.

Co-authored-by: Copilot <[email protected]>
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.

4 participants