Agent-js is throwing an error not a tuple type
.
I guess from there:
decodeValue(b, t) {
const tuple = this.checkType(t);
if (!(tuple instanceof TupleClass)) {
throw new Error('not a tuple type');
}
That’s my code:
export const setManyDocs = async ({
docs,
satellite
}: {
docs: {collection: string; doc: Doc<any>}[];
satellite: Satellite;
}): Promise<Doc<any>[]> => {
const {set_many_docs} = await getSatelliteActor(satellite);
const payload: [string, string, SetDoc][] = [];
for (const {collection, doc} of docs) {
const {key} = doc;
payload.push([collection, key, await toSetDoc(doc)]);
}
const updatedDocs = await set_many_docs(payload);
const results: Doc<any>[] = [];
for (const {doc: updatedDoc, key} of updatedDocs) {
results.push(await fromDoc({key, doc: updatedDoc}));
}
return results;
};
Nothing particular expect the usage of any
of course which I agree is not recommended but, make sense in this particular feature and it happens anyway after the error given that it fails at set_many_docs
.
chunk-V4APK5XV.js?v=7438eb6e:4329 Uncaught (in promise) Error: not a tuple type
at t6.decodeValue (chunk-V4APK5XV.js?v=7438eb6e:4329:13)
at t3.decodeValue (chunk-V4APK5XV.js?v=7438eb6e:4158:25)
at chunk-V4APK5XV.js?v=7438eb6e:4789:55
at Array.map ()
at Object.Bs (chunk-V4APK5XV.js?v=7438eb6e:4789:39)
at or2 (@junobuild_core.js?v=99bdc6e4:2480:14)
at i (@junobuild_core.js?v=99bdc6e4:2512:67)
at async ho (@junobuild_core.js?v=99bdc6e4:3217:11)
at async setMany (doc.ts:51:18)
at async document.querySelector.addEventListener.passive (doc.ts:92:45)
So, what’s wrong?