Not calling `accept_message` in inspect message not rejecting immediately in dfx 0.14.2-beta.2

A few of our tests in Azle and Kybra ensure that not calling accept_message in inspect_message rejects immediately. Some of these tests now take a very long time to complete and/or timeout, and when done output something like this:

error Error: Server returned an error:
  Code: 400 (Bad Request)
  Body: Specified ingress_expiry not within expected range:
Minimum allowed expiry: 2023-06-30 22:30:57.662984345 UTC
Maximum allowed expiry: 2023-06-30 22:36:27.662984345 UTC
Provided expiry:        2023-06-30 22:30:24.157 UTC
Local replica time:     2023-06-30 22:30:57.662986800 UTC

or

error Error: Request timed out after 300000 msec:
  Request ID: f35fc4d4ab551da8a3c119c7e7ed0f0ed9ccb16ba5b39cc790f395b8006cbe82
  Request status: unknown

    at /home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/@dfinity/agent/lib/cjs/polling/strategy.js:72:19
    at /home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/@dfinity/agent/lib/cjs/polling/strategy.js:101:19
    at async pollForResponse (/home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/@dfinity/agent/lib/cjs/polling/index.js:62:13)
    at async caller (/home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/@dfinity/agent/lib/cjs/actor.js:190:35)
    at async Proxy.<anonymous> (/home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/azle/test/index.ts:177:40)
    at async Object.test (/home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/azle/examples/inspect_message/test/tests.ts:29:36)
    at async runTests (/home/lastmjs/development/kybra/examples/inspect_message/test/node_modules/azle/test/index.ts:67:23)

I wonder if this is a regression in the replica, I would expect something more like an immediate Code: 403 (Forbidden)

Something really seems off with inspect_message now, not sure if it’s just Azle or Kybra, but seems very correlated with our upgrade to dfx 0.14.2-beta.2. Before when we did not call accept_message or we raised a Python exception (which I believe ends up in a trap), inspect_message would reject immediately. Now getting the errors above.

The new replica contains the changes announced here while the previous one did not AFAIK. Are you using dfx to make these requests? Then it could be that dfx has some bad logic in how it polls for the request state.

Here is what I’ve found:

  • The Candid UI displays the message you reported, after a long delay
  • dfx canister call with dfx 0.14.1 seems to hang indefinitely
  • dfx canister call with dfx 0.14.2 returns an error immediately
$ DFX_VERSION=0.14.2 dfx canister call inspect_message_rs_backend always_rejected
Warning: The version of DFX used (0.14.2) is different than the version being run (0.14.1).
This might happen because your dfx.json specifies an older version, or DFX_VERSION is set in your environment.
We are forwarding the command line to the old version. To disable this warning, set the DFX_WARNING=-version_check environment variable.

Error: Failed update call.
Caused by: Failed update call.
  The replica returned a replica error: Replica Error: reject code CanisterReject, reject message Canister bkyz2-fmaaa-aaaaa-qaaaq-cai rejected the message, error code Some("IC0516")

I wonder if it’s the dfinity agent then

Yep, agent-js is not in sync with the latest replica. We need the equivalent of https://github.com/dfinity/agent-rs/pull/422 in agent-js.

1 Like

For anyone looking for a temporary solution, you might be able to get around the issue by running dfx start --emulator (since the ic-ref emulator currently uses the original error handling logic).

We’ve released agent-js 0.17.0, which has the fix for this.

2 Likes