I’m using K6 and the sse extension to write some complex load tests that require a combination of http posts and SSE events. I was surprised that the “open” blocked the entire test. Someone else had run into the same problem and I added to the issue on the extension repo Support for Parallel SSE Connections · Issue #16 · phymbert/xk6-sse · GitHub. (Based on the docs, I expect the WebSocket to have the same problem.)
Anyways, my question is if it’s possible to modify the extension to call some sort of next() or trigger the main event loop some other way. For example, the main loop in the SSE extension is here: xk6-sse/sse.go at main · phymbert/xk6-sse · GitHub Could the answer be as simple as adding a next() type of call in the for loop? If so, what is the API for that call?
Welcome to our community, thanks for sharing your question here
Unfortunately, the SSE extension isn’t an official extension, which means it is maintained by the community and/or an individual contributor. So, it’s phymbert (Pierrick Hymbert) · GitHub in this case, whom you should reach to.
Could the answer be as simple as adding a next() type of call in the for loop? If so, what is the API for that call?
To make something like that possible, the function should be asynchronous, and return a Promise, then you could use async/ await as with any other asynchronous function in JS. But that’s on the developer/maintainer’s criteria to expose an asynchronous function.
Otherwise, maybe you can try to build something around, to dispatch the execution of that synchronous function, asynchronously, but if it isn’t designed with that in mind, that could cause some trouble or misbehave, so I’d encourage you to reach the extension’s developer first.