-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Making SetTimeout and co. globally available by default #3589
Comments
I feel that having these functions globally accessible is what users will expect. However, I can't say I'm a JavaScript expert, so I am unsure if my feelings are relevant. |
Similar to @olegbespalov, not a JS expert neither, but I guess that's what experienced JS users would expect, while for the rest it doesn't matter. So 👍🏻 |
For clarification and my understanding, what does the target user-experience look like? My assumption reading this is: // No need to import the `k6/timers` module
export default function () {
setTimeout(...) // timer functions are available in the runtime "natively", like in v8 browser runtimes
setInterval(...)
clearTimeout(...)
clearInterval(...)
} If so, I think that makes a lot of sense, and although I'm not completely set on that, it is also something we might want to consider also for "Web APIs" we integrate in the future (webcrypto, streams, fetch (if we do), etc...) to provide a user-experience close to what is available in other runtimes. 🙇🏻 |
Yes, that will be a thing that users will be able to do - without needing to import anything |
there is no event loop in Goja (TMK). So I am not sure who/what would call the global setInterval. Using Goja for this lib seems like a terrible mistake and frankly I am gonna run as far as I can in another direction (no offense but hopefully this helps other people..) |
@amills-vibeirl, while goja doesn't have an event loop in itself, k6 adds one. As will most projects using any js engine that want to have control over its event loop. |
Feature Description
Make the newly stabilized
k6/timers
exports:globally available
Suggested Solution (optional)
Keep the module, and just have code that imports and set them on
globalThis
by default that is run an VU initialization.Already existing or connected issues / PRs (optional)
Stabilization PR #3587
Original stabilization issue #3297
SetTimeout not being globally available #3329
The text was updated successfully, but these errors were encountered: