Response parsing error from ledger canister
Describe the bug Response parsing error. When I call icp ledger canister "ryjl3-tyaaa-aaaaa-aaaba-cai", an error occurs "Error: Call was returned undefined, but type [[object Object]]."
To Reproduce Steps to reproduce the behavior:
- use plug wallet createAgent
- createActor
- call ledger canister "ryjl3-tyaaa-aaaaa-aaaba-cai", approve function
Screenshots
- OS: MacOS
- Browser: chrome
- Version: latest
- dfinity/agent: 2.1.3 (latest)
- plug wallet: 2.2.4 (latest)
Potentially related to https://github.com/dfinity/agent-js/issues/956
PR #1014 improves the error message for such errors, see https://github.com/dfinity/agent-js/pull/1014/files#diff-8e88073ceeb119a7b39f3e6616db4c23f5d3c0e923c194f1f0e5a1a6d54f5835R531.
After the new version is released, you can try the call again, and hopefully you'll be able to debug it better.
@lenny0x can you try checking if the issue is still there and if you can debug it better with @dfinity/[email protected]?
We've just started getting this error when switching to dfx 0.28.0 in Azle's fuzz tests. A method like this:
@update([IDL.Text], IDL.Bool)
test(): boolean {
return true;
}
Will now throw the error Error: Call was returned undefined, but type [[object Object]]. after hundreds of fuzz tests. This behavior was not here before dfx 0.28.0. We didn't change anything else, just the dfx version, and then some of our fuzz tests started failing in this way.
If you change the method to a @query method the error will not be thrown. Also, the random string generated during the fuzz tests can't be used independently to reproduce the error. It seems like it will only occur after many previous fuzz test method calls.
@lastmjs I would suspect it is related to pocketic and not to dfx itself.
If possible maybe you can give repro steps and we can try it against different pocketic versions
Okay we've been narrowing this down. We have been able to reproduce it. It seems like, with just a switch from dfx 0.27.0 to dfx 0.28.0, that this Azle canister will now throw Error: Call was returned undefined, but type [[object Object]] when test is called in rapid succession with a text argument of size 100_000.
Here's the simple Azle canister:
import { IDL, update } from 'azle';
export default class {
@update([IDL.Text], IDL.Bool)
test(): boolean {
return true;
}
}
Here's our test case that invokes the error condition. Basically just call test 50 times without awaiting with a text argument of size 100_000:
import { ActorSubclass } from '@dfinity/agent';
import { it, Test } from 'azle/_internal/test';
import { _SERVICE } from './dfx_generated/broken_text_argument/broken_text_argument.did';
export function getTests(actor: ActorSubclass<_SERVICE>): Test {
return () => {
it('burst calls test with a large text argument', async () => {
for (let i = 0; i < 50; i++) {
actor.test(new Array(100_000).fill('0').join(''));
}
});
};
}
Notice that we do not await actor.test, this is necessary to put the replica under enough load to invoke the error (that's my theory).
I haven't been able to reproduce this in a Rust canister. Even a text argument up to 2_000_000 in size wouldn't invoke this condition.