Query trigger additionalScope parameters incorrectly reused between await calls

Simply, if you do await query.trigger({additionalScope: {} }) multiple times in a javascript query, the additionalScope is reused from the first call for every other trigger call. Here is a simple reproduction

If this is intended behavior, this is surprising. I'm trying to replicate and simplify Returning all results for a cursor-based paginated API which was before trigger was using promises.

Actually no, it's worse than that. additionalScope is always cached for the lifetime of the Javascript query. Using the exact example from @antonybello, which does not await on trigger, we can see that the query discards additionalScope after the first call. This seems pretty major.

Alright, I actually think this is working internally and my analysis was somewhat incorrect. It looks like trigger does use additionalScope properly, the API I'm using isn't consistent. That part does work.

However! There does appear to be a bug with the beta debug console then, as it's getting values from... I don't know where. It's definitely not showing the right data for the query.

Hi Rory! Thank you for bringing this to our attention. So basically the new debug console sent you in the wrong direction, huh? I'll see if I can reproduce this on my end. Thank you again!

Yes, that's a good succinct way of saying it. The debug console, while useful, lead me down the wrong path by displaying incorrect values for the query parameters.

@Rory - quick update! We filed this as a bug to be addressed, so we'll ping in this thread with any updates. Please do let us know if you run into any other issue with this feature. We definitely expect to find a few more hiccups while it's in beta :sweat_smile: