Repository navigation
feat(pic): add options to makeLive - #314
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Failed gateway startup leaves auto-progress enabled and the instance in an inconsistent state.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Adds configurable live-mode delays and HTTP gateway settings, plus guidance and tests for interleaved calls.
Changes:
- Adds
MakeLiveOptionsand forwards gateway/delay configuration. - Tests live-mode configuration and deferred-call interleaving.
- Updates examples and testing documentation.
| File | Description |
|---|---|
packages/pic/tests/test-canister/test_canister.did |
Adds interleaving test methods. |
packages/pic/tests/test-canister/main.mo |
Implements lost-update test behavior. |
packages/pic/tests/test-canister/declarations/test_canister.did.js |
Updates generated JavaScript declarations. |
packages/pic/tests/test-canister/declarations/test_canister.did.d.ts |
Updates generated TypeScript declarations. |
packages/pic/tests/src/util.ts |
Extracts the free-port helper. |
packages/pic/tests/src/live-mode.spec.ts |
Tests live-mode options and validation. |
packages/pic/tests/src/http-gateway.spec.ts |
Uses the shared port helper. |
packages/pic/tests/src/create-actor.spec.ts |
Tests deferred-call interleaving. |
packages/pic/src/pocket-ic.ts |
Extends makeLive and fixes examples. |
packages/pic/src/pocket-ic-types.ts |
Defines public live-mode options. |
packages/pic/src/pocket-ic-client.ts |
Forwards options to server endpoints. |
packages/pic/src/pocket-ic-client-types.ts |
Exports gateway configuration encoding. |
docs/src/content/docs/guides/running-tests.mdx |
Documents interleaving and live mode. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
marc0olo
marked this pull request as draft
September 29, 2026 11:29
…to feat/make-live-options # Conflicts: # packages/pic/tests/src/create-actor.spec.ts
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The new API behavior, rollback path, tests, example, and documentation are consistent and complete.
Review effort: Balanced
Findings: None
Resolved since last review (3)
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
marc0olo
added this pull request to stack #317
September 30, 2026 07:48
marc0olo
marked this pull request as ready for review
September 30, 2026 07:55
lwshang
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #142
makeLivetakes an optional options object:artificialDelayMs, the minimum delay between rounds. It was hard-coded to0. It delays calls that wait for live mode to execute them: calls through the HTTP gateway, and submitted calls polled withingressStatus. Actors, deferred actors,updateCallandawaitCallexecute their rounds themselves, so they aren't delayed. Measured: an update through an agent took ~700 ms with a 300 ms delay, and a polled submitted call took ~1 s with a 1 s delay, but the others took 3–10 ms either way.httpGateway, the same settings asPocketIc.create'shttpGateway(IP address, port, domains, HTTPS), for the gatewaymakeLivestarts.Passing options to an instance that's already live, or
httpGatewayto one created with its own gateway, throws instead of ignoring them. If the gateway fails to start, e.g. because its port is taken, auto progress is stopped again, so the instance isn't left live without a gateway.For the reentrancy case in #142, live mode isn't needed: calls submitted with a deferred actor before any is awaited interleave at their
awaits. A newexamples/reentrancyexample shows it (its test for the vulnerable withdrawal relies on #315, since the second withdrawal traps) with a bank canister: a withdrawal that checks the balance before awaiting a transfer and deducts it after pays out twice, the fixed one pays out once, and a regular actor making the calls one after another misses the bug.running-tests.mdxgets short sections on testing interleaved calls (linking the example) and on live mode, and the example lists now mention both Jest and Vitest. The example is built with the Motoko recipe v5.1.0, which compiles throughmops build, so it's defined in[canisters]ofmops.toml;.gitignorenow ignores.mops/at any depth for its build output. The other examples move to v5 in a follow-up.The
makeLiveJSDoc said the instance needs an NNS subnet forfetchRootKey. That's not the case on PocketIC 16 (checked with an agent against an instance without one), so it's removed. The broken code examples ofmakeLiveandstopLiveare fixed.🤖 Generated with Claude Code