Closed wildhart closed 1 month ago
I will take a closer look soon but out of curiosity, is this with Meteor 2.16
? Can you repro with 2.14
or 3.0.2
?
Yes, this is 2.16. I will try 2.14 later and let you know how I get on...
I wasn't able to reproduce with async / await syntax.
async onButtonClick() {
// simulate doing something async:
await new Promise(resolve => setTimeout(resolve, 100));
await siteInspectionMethods.upsertJam({_id: Random.id()});
}
I was able to reproduce with
onButtonClick() {
new Promise(resolve => setTimeout(resolve, 100)).then(() => {
siteInspectionMethods.upsertJam({_id: Random.id()});
});
}
And more importantly I was able to reproduce without using jam:method
:
onButtonClick() {
new Promise(resolve => setTimeout(resolve, 100)).then(() => {
Meteor.callAsync(methodName, ...args)
});
}
I think this issue lies with Meteor 2.x
itself and not this package. I remember a discussion a while back about some limitations with regard to *Async
collection methods. I think some (maybe all) of those limitations were captured here: https://github.com/zodern/fix-async-stubs# which led to zodern's solution being incorporated into 3.x
FYI I was able to reproduce on Meteor 2.14
Installing meteor add zodern:fix-async-stubs
seems to resolve the issue, thanks for that. Feel free to close this issue.
This is a weird bug which occurs when calling a method to insert or upsert a document into a collection after a UI button click but first doing something
async
.Steps to reproduce
Packages:
jam:method@1.7.1
jam:offline@0.2.2
- howeverkeepAll
is false, and for the purposes of this repro I've not calledkeep()
on this collection, and the bug occurs when online, so I'm pretty sure this bug is not injam:offline
.Here's my method - just a simple
upsertAsync
(but I've also triedinsertAsync
, and the sync versions with the same error result).And then a simple click handler in the UI:
Clicking the button causes this error (note that none of these trace lines are in
jam:offline
orjam:method
):If you remove the
await new Promise(resolve => setTimeout(resolve, 100));
line, then it works without an error, and the document is upserted correctly.If I remove
jam:method
by defining a simple method instead:Then call this method instead, after the delay:
Then it works OK without any error messages.
This also works:
But this FAILS with the same error:
Any ideas? Can you repro this?