From b6e7ee3ece120bd752135651b55d329ba568c249 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Wed, 3 Jul 2024 15:22:01 +0300 Subject: [PATCH 01/24] v0.53.0 release notes initial commit --- release notes/v0.53.0.md | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 release notes/v0.53.0.md diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md new file mode 100644 index 00000000000..a8e0e986f5e --- /dev/null +++ b/release notes/v0.53.0.md @@ -0,0 +1,47 @@ +k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: + +- (_optional_) `` +- `` (_one or multiple bullets_) + + +## Breaking changes + +- `#pr`, `` +- `#pr`, `` + +### (_optional h3_) `` `#pr` + +## New features + +_optional intro here_ + +### `` `#pr` + +_what, why, and what this means for the user_ + +### `` `#pr` + +_what, why, and what this means for the user_ + +## UX improvements and enhancements + +_Format as ` . `_: + +- _`#999` Gives terminal output prettier printing. Thanks to `@person` for the help!_ +- `#pr` `` +- `#pr` `` + +## Bug fixes + +_Format as ` . `_: +- _`#111` fixes race condition in runtime_ + +## Maintenance and internal improvements + +_Format as ` . `_: +- _`#2770` Refactors parts of the JS module._ + +## _Optional_ Roadmap + +_Discussion of future plans_ + From 88f7dfb36b4823b884578025b0b529b504962c42 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Thu, 25 Jul 2024 11:41:09 +0200 Subject: [PATCH 02/24] doc: opentelemetry --- release notes/v0.53.0.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index a8e0e986f5e..0b491c5e211 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -15,9 +15,17 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: _optional intro here_ -### `` `#pr` +### OpenTelemetry experimental output `#3834` -_what, why, and what this means for the user_ +This release introduces a new experimental output for OpenTelemetry. This allows users to send k6 metrics to any OpenTelemetry-compatible backends. More details and usage examples could be found in the [documentation](https://grafana.com/docs/k6/latest/results-output/real-time/opentelemetry/). + +To output metrics to OpenTelemetry, use the `experimental-opentelemetry` output option: + +```bash + k6 run -o experimental-opentelemetry examples/script.js +``` + +If you have any feedback or issues, please let us know directly in [the extension repository](https://github.com/grafana/xk6-output-opentelemetry/issues). ### `` `#pr` From d2c345516ed92fb4d8d2719ddbeeec35cef5a081 Mon Sep 17 00:00:00 2001 From: Oleg Bespalov Date: Thu, 25 Jul 2024 11:46:29 +0200 Subject: [PATCH 03/24] More release notes from Oleg --- release notes/v0.53.0.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 0b491c5e211..1f6e593bd35 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -1,6 +1,7 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: - (_optional_) `` +- experimental OpenTelemetry output - `` (_one or multiple bullets_) @@ -51,5 +52,9 @@ _Format as ` . `_: ## _Optional_ Roadmap -_Discussion of future plans_ +### Future breaking changes + +#### StatsD removal + +This release we also fixed the version where we will remove the StatsD output. The StatsD output will be removed in the `v0.55.0` release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). From 75b3c999b5b21e792aaadd80fed112c91f8e4ea9 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Thu, 25 Jul 2024 13:15:16 +0300 Subject: [PATCH 04/24] Most release notes changes --- release notes/v0.53.0.md | 157 +++++++++++++++++++++++++++++++++------ 1 file changed, 135 insertions(+), 22 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 1f6e593bd35..0c11a31f1f0 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -1,22 +1,139 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: -- (_optional_) `` -- experimental OpenTelemetry output -- `` (_one or multiple bullets_) - +- Native ECMAScript modules support :tada:! +- New experimental OpenTelemetry metrics output :rocket:! +- Blob support in experimental websockets module :blob: +- Consolidating cloud features and commands under `k6 cloud` :cloud: +- Breaking change: remove magic URL resolutions :stop_sign: ## Breaking changes -- `#pr`, `` -- `#pr`, `` +### ECMAScript Modules(ESM) Native Support related breaking changes: + +As part of the implementation two common patterns that are broken in the ecosystem became apparent. + +One of them is arguably a DX improvement, the other was a consequence of the previous implementation. + +#### Mixing CommonJS and ESM + +Previously k6 was using a transpiler(Babel) internally to transpile ESM syntax to CommonJS. That lead to all code always being CommonJS and that if you had CommonJS next to it, Babel will not complain. + +As k6 (or the underlying JS VM implementation) did not understand ESM in of itself and that CommonJS is 100% during execution feature - this was not easy to detect or prevent. + +A [warning](https://github.com/grafana/k6/pull/3807) was added in v0.52.0 in try to warn users as soon as possible. + +To fix this - all you need is to just stick to either CommonJS or ESM withing each file. + +
+ Code examples and proposed changes + +```javascript +import { sleep } from "k6"; + +module.exports.default = func() { ...} +``` + +In the example above both ESM and CommonJS are used in the same file. + +Either replace +```javascript +module.exports.default = func() {} +``` + +with the ESM syntax + +```javascript +export default func() {} +``` + +or replace + +```javascript +import { sleep } from "k6"; +``` + with the CommonJS: -### (_optional h3_) `` `#pr` +```javascript +const sleep = require("k6").sleep; +``` + +
+#### Imported identifier that can't be resolved are now errors + +Previously to this if you were using the ESM syntax but imported identifier `foo` but the exporting file didn't export it - there will be no error. + +bar.js: +```javascript +export const notfoo = 5; +``` +main.js + +```javascript +import { foo } from "./bar.js" +export default function () { + foo.bar(); // throws exception here +} +``` +It would not error out, but on accessing it - there will be an exception as it will be `undefined`. + +With native ESM support that is an error as defined by the specification and will error out sooner. + +This arguably is an improvement to UX/DX, but we have reports that there are users who have imports like this, but do not use them. So they wouldn't be getting exceptions, but they will now get errors. + +The solution in this case is to stop importing the not exported identifiers. + +### No more "magic" URL resolution + +For a long time k6 has supported special/magic URLs that aren't really that. + +Those were URLs without a scheme, that : +1. started with `github.com` that if pasted in a browser will not open you the file. Their appeal was that you can more easily write them by hand if you know the path within a github repo. +2. started with `cdnjs.com` that if pasted in a browser will open an web page with all the versions of the library. The appeal here is that you will get the latest version. + +Both of them had problems though. + +The github ones seemed to have never be used by users, likely because you need to guess what the path should look like, and you can always just go get a real URL to the raw file. + +While the cdnjs ones have some more usage, they are both a lot more complicated to support, as they require multiple requests to figure out what needs to be loaded. They also change over time. In addition the only known use at the moment is based on a very old example from an issue and it is even pointing to concrete, old version, of a library. + +Given that this can be done with a normal URL, we have decided to drop support for this and have warned users for the last couple of versions. + +### Deprecated `k6/experimental/tracing` in favor of a jslib + +`k6/experimental/tracing` is arguably not very well named, and there is good chances we would like to use the name for actual trace and span support within k6 in the future. + +On top of that it can now be fully supported in js code, which is why [http-instrumentation-tempo +](https://grafana.com/docs/k6/latest/javascript-api/jslib/http-instrumentation-tempo/) was created. + +The jslib is a drop in replacement so all you need to do is replace `k6/experimental/tracing` with `https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js`. + +The module is planned to be removed in v0.55.0, planned for November 11th, 2024. + +### Experimental websockets now require `binaryType` to be set to receive binary messages + +As part of the stabilization of the `k6/experimental/websockets` we need to move the default value of `binaryType` to `blob`. It was previously `arraybuffer` and since the last version there was a warning that it needs to be set in order for binary messages to be received. + +That warning is now an error. + +In the future we will move the default value to `blob` and remove the error. ## New features -_optional intro here_ +The new features include: +- Native ESM support, which also brings some quality of life JavaScript features +- Blob support in the experimental websockets module. +- Experimental OpenTelemetry metrics output. +- Consolidating cloud related commands and features under `k6 cloud` + +### Native ESM support [#3456](https://github.com/grafana/k6/pull/3456) + +TODO: expand, talk about additional JavaScript features now support, top-level-await, dynamic import, compatibility-mode history -### OpenTelemetry experimental output `#3834` +### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) + +// TODO + +### Experimental OpenTelemetry Output [#3834](https://github.com/grafana/k6/pull/3834) This release introduces a new experimental output for OpenTelemetry. This allows users to send k6 metrics to any OpenTelemetry-compatible backends. More details and usage examples could be found in the [documentation](https://grafana.com/docs/k6/latest/results-output/real-time/opentelemetry/). @@ -28,33 +145,29 @@ To output metrics to OpenTelemetry, use the `experimental-opentelemetry` output If you have any feedback or issues, please let us know directly in [the extension repository](https://github.com/grafana/xk6-output-opentelemetry/issues). -### `` `#pr` +### Consolidating cloud features under `k6 cloud` [#3813](https://github.com/grafana/k6/pull/3813) -_what, why, and what this means for the user_ +// TODO ## UX improvements and enhancements -_Format as ` . `_: - -- _`#999` Gives terminal output prettier printing. Thanks to `@person` for the help!_ -- `#pr` `` -- `#pr` `` - +- [#3783](https://github.com/grafana/k6/pull/3783) Set correct exit code on invalid configurations. Thank you @ariasmn! ## Bug fixes -_Format as ` . `_: -- _`#111` fixes race condition in runtime_ +- [#3845](https://github.com/grafana/k6/pull/3845) Fix logging to file sometimes missing lines. Thank you @roobre! ## Maintenance and internal improvements -_Format as ` . `_: -- _`#2770` Refactors parts of the JS module._ +- [#3792](https://github.com/grafana/k6/pull/3792), [#3817](https://github.com/grafana/k6/pull/3817), [#3863](https://github.com/grafana/k6/pull/3863) Finalize moving to Sobek, our fork of goja. +- [#3815](https://github.com/grafana/k6/pull/3815), [#3840](https://github.com/grafana/k6/pull/3840), [#3821](https://github.com/grafana/k6/pull/3821), [#3836](https://github.com/grafana/k6/pull/3836), [#3840](https://github.com/grafana/k6/pull/3840), [#3844](https://github.com/grafana/k6/pull/3844), [#3821](https://github.com/grafana/k6/pull/3821) Update dependencies. +- [#3830](https://github.com/grafana/k6/pull/3830), [#3831](https://github.com/grafana/k6/pull/3831), [#3862](https://github.com/grafana/k6/pull/3862) Refactoring and cleanup around ESM PR. + ## _Optional_ Roadmap +// TODO: top-level-await, dynamic import, import.meta.resolve, `global` and compatibility-mode?!? ### Future breaking changes #### StatsD removal This release we also fixed the version where we will remove the StatsD output. The StatsD output will be removed in the `v0.55.0` release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). - From f46621ad056997a14ce3984cc6cca08bd4f4a524 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:38:42 +0300 Subject: [PATCH 05/24] Apply suggestions from code review Co-authored-by: Oleg Bespalov --- release notes/v0.53.0.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 0c11a31f1f0..c648c5f528d 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -2,7 +2,7 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: - Native ECMAScript modules support :tada:! - New experimental OpenTelemetry metrics output :rocket:! -- Blob support in experimental websockets module :blob: +- Blob support in experimental websockets module - Consolidating cloud features and commands under `k6 cloud` :cloud: - Breaking change: remove magic URL resolutions :stop_sign: @@ -10,19 +10,19 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: ### ECMAScript Modules(ESM) Native Support related breaking changes: -As part of the implementation two common patterns that are broken in the ecosystem became apparent. +As part of the implementation, two common patterns broken in the ecosystem became apparent. -One of them is arguably a DX improvement, the other was a consequence of the previous implementation. +One is arguably a developer experience improvement, and the other is a consequence of the previous implementation. #### Mixing CommonJS and ESM -Previously k6 was using a transpiler(Babel) internally to transpile ESM syntax to CommonJS. That lead to all code always being CommonJS and that if you had CommonJS next to it, Babel will not complain. +Previously, k6 used a transpiler (Babel) internally to transpile ESM syntax to CommonJS. That led to all code always being CommonJS, and if you had CommonJS next to it, Babel would not complain. -As k6 (or the underlying JS VM implementation) did not understand ESM in of itself and that CommonJS is 100% during execution feature - this was not easy to detect or prevent. +As k6 (or the underlying JS VM implementation) did not understand ESM in itself and that CommonJS is a 100% during execution feature, this was not easy to detect or prevent. -A [warning](https://github.com/grafana/k6/pull/3807) was added in v0.52.0 in try to warn users as soon as possible. +We added a [warning](https://github.com/grafana/k6/pull/3807) in v0.52.0 to give users time for migration. -To fix this - all you need is to just stick to either CommonJS or ESM withing each file. +To fix this - all you need is to stick to either CommonJS or ESM within each file.
Code examples and proposed changes @@ -74,17 +74,17 @@ export default function () { foo.bar(); // throws exception here } ``` -It would not error out, but on accessing it - there will be an exception as it will be `undefined`. +It would not error out, but when it is accessed, there will be an exception as it will be `undefined`. -With native ESM support that is an error as defined by the specification and will error out sooner. +With native ESM support, that is an error as defined by the specification and will occur sooner. -This arguably is an improvement to UX/DX, but we have reports that there are users who have imports like this, but do not use them. So they wouldn't be getting exceptions, but they will now get errors. +This arguably improves UX/DX, but we have reports that some users have imports like this but do not use them. So, they wouldn't be getting exceptions, but they would now get errors. -The solution in this case is to stop importing the not exported identifiers. +The solution, in this case, is to stop importing the not exported identifiers. ### No more "magic" URL resolution -For a long time k6 has supported special/magic URLs that aren't really that. +For a long time, k6 has supported special "magic" URLs that aren't really that. Those were URLs without a scheme, that : 1. started with `github.com` that if pasted in a browser will not open you the file. Their appeal was that you can more easily write them by hand if you know the path within a github repo. @@ -98,16 +98,16 @@ While the cdnjs ones have some more usage, they are both a lot more complicated Given that this can be done with a normal URL, we have decided to drop support for this and have warned users for the last couple of versions. -### Deprecated `k6/experimental/tracing` in favor of a jslib +### Deprecated `k6/experimental/tracing` in favor of a JavaScript implementation `k6/experimental/tracing` is arguably not very well named, and there is good chances we would like to use the name for actual trace and span support within k6 in the future. On top of that it can now be fully supported in js code, which is why [http-instrumentation-tempo ](https://grafana.com/docs/k6/latest/javascript-api/jslib/http-instrumentation-tempo/) was created. -The jslib is a drop in replacement so all you need to do is replace `k6/experimental/tracing` with `https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js`. +The JavaScript implementation is a drop-in replacement, so all you need to do is replace `k6/experimental/tracing` with `https://jslib.k6.io/http-instrumentation-tempo/1.0.0/index.js`. -The module is planned to be removed in v0.55.0, planned for November 11th, 2024. +The module is [planned to be removed in v0.55.0](https://github.com/grafana/k6/pull/3855), planned for November 11th, 2024. ### Experimental websockets now require `binaryType` to be set to receive binary messages @@ -127,7 +127,7 @@ The new features include: ### Native ESM support [#3456](https://github.com/grafana/k6/pull/3456) -TODO: expand, talk about additional JavaScript features now support, top-level-await, dynamic import, compatibility-mode history +TODO: expand, talk about additional JavaScript features now support, top-level-await, dynamic import, compatibility-mode history, performance improvements ### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) @@ -170,4 +170,4 @@ If you have any feedback or issues, please let us know directly in [the extensio #### StatsD removal -This release we also fixed the version where we will remove the StatsD output. The StatsD output will be removed in the `v0.55.0` release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). +In this release, we also fixed the version where we will remove the StatsD output. The StatsD output [is going to be removed in the `v0.55.0`](https://github.com/grafana/k6/pull/3849) release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). From 99dffcd5ae296f8296ec00c406771714e8aa90df Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Fri, 26 Jul 2024 14:39:09 +0300 Subject: [PATCH 06/24] Apply suggestions from code review Co-authored-by: Johan Suleiko Allansson --- release notes/v0.53.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index c648c5f528d..bd06271240e 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -168,6 +168,10 @@ If you have any feedback or issues, please let us know directly in [the extensio ### Future breaking changes +#### Experimental browser module removal + +In the previous release, the browser module graduated from experimental to stable. The `k6/experimental/browser` module will be removed in `v0.54.0`. To keep your scripts working you need to [migrate to the `k6/browser` module](https://grafana.com/docs/k6/latest/using-k6-browser/migrating-to-k6-v0-52/). + #### StatsD removal In this release, we also fixed the version where we will remove the StatsD output. The StatsD output [is going to be removed in the `v0.55.0`](https://github.com/grafana/k6/pull/3849) release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). From 928e0d6246cc9c32d578b0ab1de01673bce480c4 Mon Sep 17 00:00:00 2001 From: Johan Suleiko Allansson Date: Fri, 26 Jul 2024 16:48:13 +0200 Subject: [PATCH 07/24] add browser related issues --- release notes/v0.53.0.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index bd06271240e..ffa0a25090b 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -152,15 +152,18 @@ If you have any feedback or issues, please let us know directly in [the extensio ## UX improvements and enhancements - [#3783](https://github.com/grafana/k6/pull/3783) Set correct exit code on invalid configurations. Thank you @ariasmn! + ## Bug fixes - [#3845](https://github.com/grafana/k6/pull/3845) Fix logging to file sometimes missing lines. Thank you @roobre! +- [browser#1391](https://github.com/grafana/xk6-browser/pull/1391) Fix race conditions in internal event handling. ## Maintenance and internal improvements - [#3792](https://github.com/grafana/k6/pull/3792), [#3817](https://github.com/grafana/k6/pull/3817), [#3863](https://github.com/grafana/k6/pull/3863) Finalize moving to Sobek, our fork of goja. - [#3815](https://github.com/grafana/k6/pull/3815), [#3840](https://github.com/grafana/k6/pull/3840), [#3821](https://github.com/grafana/k6/pull/3821), [#3836](https://github.com/grafana/k6/pull/3836), [#3840](https://github.com/grafana/k6/pull/3840), [#3844](https://github.com/grafana/k6/pull/3844), [#3821](https://github.com/grafana/k6/pull/3821) Update dependencies. - [#3830](https://github.com/grafana/k6/pull/3830), [#3831](https://github.com/grafana/k6/pull/3831), [#3862](https://github.com/grafana/k6/pull/3862) Refactoring and cleanup around ESM PR. +- [browser#1389](https://github.com/grafana/xk6-browser/pull/1389) Move deserialization of `BrowserContextOptions` into mapping layer. ## _Optional_ Roadmap From 54d56a105e1a1934e6f7d4d7f05e356bac428851 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Fri, 26 Jul 2024 17:48:46 +0300 Subject: [PATCH 08/24] todo additions --- release notes/v0.53.0.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index ffa0a25090b..a3610912386 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -8,6 +8,8 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: ## Breaking changes +//TODO: https://github.com/grafana/k6/issues/3534 + ### ECMAScript Modules(ESM) Native Support related breaking changes: As part of the implementation, two common patterns broken in the ecosystem became apparent. @@ -152,9 +154,11 @@ If you have any feedback or issues, please let us know directly in [the extensio ## UX improvements and enhancements - [#3783](https://github.com/grafana/k6/pull/3783) Set correct exit code on invalid configurations. Thank you @ariasmn! +- https://github.com/grafana/k6/pull/3868 ## Bug fixes +- https://github.com/grafana/k6/pull/3746 - [#3845](https://github.com/grafana/k6/pull/3845) Fix logging to file sometimes missing lines. Thank you @roobre! - [browser#1391](https://github.com/grafana/xk6-browser/pull/1391) Fix race conditions in internal event handling. @@ -164,6 +168,10 @@ If you have any feedback or issues, please let us know directly in [the extensio - [#3815](https://github.com/grafana/k6/pull/3815), [#3840](https://github.com/grafana/k6/pull/3840), [#3821](https://github.com/grafana/k6/pull/3821), [#3836](https://github.com/grafana/k6/pull/3836), [#3840](https://github.com/grafana/k6/pull/3840), [#3844](https://github.com/grafana/k6/pull/3844), [#3821](https://github.com/grafana/k6/pull/3821) Update dependencies. - [#3830](https://github.com/grafana/k6/pull/3830), [#3831](https://github.com/grafana/k6/pull/3831), [#3862](https://github.com/grafana/k6/pull/3862) Refactoring and cleanup around ESM PR. - [browser#1389](https://github.com/grafana/xk6-browser/pull/1389) Move deserialization of `BrowserContextOptions` into mapping layer. +- https://github.com/grafana/k6/pull/3841 +- https://github.com/grafana/k6/pull/3837 + https://github.com/grafana/k6/pull/3847 +- https://github.com/grafana/k6/pull/3870 +- https://github.com/grafana/k6/pull/3851 ## _Optional_ Roadmap From 745974cf0354be4524be76d703cba9748678a9ea Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Fri, 26 Jul 2024 18:21:38 +0300 Subject: [PATCH 09/24] Add require breaking changes --- release notes/v0.53.0.md | 44 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index a3610912386..54c83aa17fb 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -8,7 +8,49 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: ## Breaking changes -//TODO: https://github.com/grafana/k6/issues/3534 +### Require is now specification compliant and always resolve based on the file it is written in [#3534](https://github.com/grafana/k6/issues/3534) + +`require` in k6 used to resolve identifiers based on the current "root of execution"(more on that later). In a lot of cases that aligns with the file the `require` is written in or a file in the same folder, which leads to the same result. In small subset of cases this isn't case. + +Every other implementation and more or less by the CommonJS specification - require should always be relative to the file it is written in. + +This also aligns with how ESM and dynamic `import` also work. In order to align with them `require` now uses the same underlying implementation. + +There was a warning message for the last 2 releases trying to tease out cases where that would be problematic. + +
+ "root of exeuction" explanation +This is very much an implementation detail that has leaked and likely a not intended one. + +Whenever a file is `require`-ed it become the "root of execution" and both `require` and `open` become relative to it. Once the `require` finishes, the previous "root of execution" gets restored. During not init context execution, the main file is the "root of execution". + +Example: + +Have 3 files: +main.js +```javascript +const s = require("./A/a.js") +if (s() != 5) { + throw "Bad" +} +module.exports.default = () =>{} // just for k6 to not error +``` + +/A/a.js: +```javascript +module.exports = function () { + return require("./b.js"); +} +``` +/A/b.js +```javascript +module.exports = 5 +``` +In this example when `require` is called in `/A/a.js` the `main.js` is once again the "root of execution". If you call the function in `/A/a.js` just after defining it though, it will work as expected. + +
Date: Mon, 29 Jul 2024 17:09:11 +0300 Subject: [PATCH 10/24] Add ESM release notes --- release notes/v0.53.0.md | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 54c83aa17fb..72528d75c9a 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -102,6 +102,7 @@ const sleep = require("k6").sleep; ```
+ #### Imported identifier that can't be resolved are now errors Previously to this if you were using the ESM syntax but imported identifier `foo` but the exporting file didn't export it - there will be no error. @@ -171,7 +172,42 @@ The new features include: ### Native ESM support [#3456](https://github.com/grafana/k6/pull/3456) -TODO: expand, talk about additional JavaScript features now support, top-level-await, dynamic import, compatibility-mode history, performance improvements +With this feature k6 is now ES6+ compliant natively. Which means (asterisk free) support for [the spread operator with object](https://github.com/grafana/k6/issues/824), [private class fields](https://github.com/grafana/k6/issues/2887) and [optional chaining](https://github.com/grafana/k6/issues/2168) + +But also faster startup times, more consistent errors and easier addition of features as we now only need to add them to Sobek instead of also them being supported in the internal Babel. + +
+ History of compatibility mode and ECMAScript specification compliance + +Some history: More than 6 years go k6 started using core-js and babel to get ES6+ features. core-js is implementation of a lot of the types and their features such as [`String.prototype.matchAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) among other things, and Babel gets one piece of code that uses some syntax and returns a piece of code doing the same thing (mostly) but with different syntax. Usually with the idea of supporting newer syntax but returning code that can run on runtimes which only support old syntax. + +This is great, but it means that: +1. For core-js each VU needs to run a bunch of JS code each initialization so it can polyfill everything that is missing +2. Babel needs to be parsed and loaded and then given files to transpile on each start. + +Both of those aren't that big problems usually, but the runtime k6 uses is fairly fast, but isn't V8. What it lacks in speed it gets back in being easy to interact with from Go, the language k6 is written in. + +But it means that now on each start it needs to do a bunch of work that adds up. + +So long time ago for people who would want to not have to do this we added [compatibility-mode=base](https://github.com/grafana/k6/pull/1206). This allowed you to potentially not use this features and get a big speedup. Or use them outside of k6 and likely still get significant speed up if you cut down on it. + +At the same time the author and maintainer of the JS runtime we used (goja) did implement a *big* portion of what we were missing from core-js and also Babel. After some experiments to cut down the core-js we import we ended up contributing back the remaining parts and dropping the whole library. Which lead to 5 times reduction of memory per VU for simple scripts. And even for fairly complicated ones. + +With this in mind we did try to cut down Babel as well and contribute back the simpler things it was used for. This over the years lead to small pieces of what Babel did being moved to goja and then disabled in Babel. Some of those were just easy wins, some of those were things that had very bad pathological cases where using a particular syntax made transpilation times explode. + +In all of that work there always were small (or not so small) breaking changes due to many factors - sometimes our new implementation was slightly wrong and we needed to fix, sometimes more than what was in the standard was enabled in core-js or Babel, sometimes hthe standard changed on those. And sometimes the implementation in Babel or core-js wasn't as full and didn't account for all corner cases. + +ECMAScript Modules(ESM) is the last such feature that Babel was used for. It also happens to be likely the one *most* people used, due to the fact that it is the standard way to reuse code and import libraries. + +While the work on this feature started over 2 years ago, it both depended on other features that weren't there yet, but also interacts with more or less every other feature that is part of the ECMAScript standard. + +Along the way there were many internal refactors as well as additional tests to make certain we can be as backwards compatible as possible. But there also ended up being things that just weren't going to be compatible, like the listed breaking changes. + +
+ +After ESM now being natively supported, compatibility-mode `base` vs `extended` has only 1 feature difference - aliasing `global` to `globalThis` to make it a bit more compatible with (old) Node.js. There is ongoing [discussion](https://github.com/grafana/k6/issues/3864) if that as well should be removed. + +For the purposes of having less intrusive changes and shipping this earlier a few things have not been implemented in k6. That includes top-level-await and dynamic import support. Both of them are likely to land in the next version. ### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) From 795be3f1bb0907194189b499bbde90ef0f1976ac Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:16:53 +0300 Subject: [PATCH 11/24] Apply suggestions from code review Co-authored-by: Ivan <2103732+codebien@users.noreply.github.com> --- release notes/v0.53.0.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 72528d75c9a..d855d3dcdb0 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -10,7 +10,7 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: ### Require is now specification compliant and always resolve based on the file it is written in [#3534](https://github.com/grafana/k6/issues/3534) -`require` in k6 used to resolve identifiers based on the current "root of execution"(more on that later). In a lot of cases that aligns with the file the `require` is written in or a file in the same folder, which leads to the same result. In small subset of cases this isn't case. +`require` in k6 used to resolve identifiers based on the current "root of execution" (more on that later). In a lot of cases that aligns with the file the `require` is written in or a file in the same folder, which leads to the same result. In a small subset of cases, this isn't the case. Every other implementation and more or less by the CommonJS specification - require should always be relative to the file it is written in. @@ -129,9 +129,9 @@ The solution, in this case, is to stop importing the not exported identifiers. ### No more "magic" URL resolution -For a long time, k6 has supported special "magic" URLs that aren't really that. +For a long time, k6 has supported special _magic_ URLs that aren't really that. -Those were URLs without a scheme, that : +Those were URLs without a scheme, that: 1. started with `github.com` that if pasted in a browser will not open you the file. Their appeal was that you can more easily write them by hand if you know the path within a github repo. 2. started with `cdnjs.com` that if pasted in a browser will open an web page with all the versions of the library. The appeal here is that you will get the latest version. @@ -166,8 +166,8 @@ In the future we will move the default value to `blob` and remove the error. The new features include: - Native ESM support, which also brings some quality of life JavaScript features -- Blob support in the experimental websockets module. -- Experimental OpenTelemetry metrics output. +- Blob support in the experimental websockets module +- Experimental OpenTelemetry metrics output - Consolidating cloud related commands and features under `k6 cloud` ### Native ESM support [#3456](https://github.com/grafana/k6/pull/3456) @@ -242,8 +242,8 @@ If you have any feedback or issues, please let us know directly in [the extensio ## Maintenance and internal improvements -- [#3792](https://github.com/grafana/k6/pull/3792), [#3817](https://github.com/grafana/k6/pull/3817), [#3863](https://github.com/grafana/k6/pull/3863) Finalize moving to Sobek, our fork of goja. -- [#3815](https://github.com/grafana/k6/pull/3815), [#3840](https://github.com/grafana/k6/pull/3840), [#3821](https://github.com/grafana/k6/pull/3821), [#3836](https://github.com/grafana/k6/pull/3836), [#3840](https://github.com/grafana/k6/pull/3840), [#3844](https://github.com/grafana/k6/pull/3844), [#3821](https://github.com/grafana/k6/pull/3821) Update dependencies. +- [#3792](https://github.com/grafana/k6/pull/3792), [#3817](https://github.com/grafana/k6/pull/3817), [#3863](https://github.com/grafana/k6/pull/3863) Finalize moving to Sobek, our fork of goja. +- [#3815](https://github.com/grafana/k6/pull/3815), [#3840](https://github.com/grafana/k6/pull/3840), [#3821](https://github.com/grafana/k6/pull/3821), [#3836](https://github.com/grafana/k6/pull/3836), [#3840](https://github.com/grafana/k6/pull/3840), [#3844](https://github.com/grafana/k6/pull/3844), [#3821](https://github.com/grafana/k6/pull/3821) Update dependencies. - [#3830](https://github.com/grafana/k6/pull/3830), [#3831](https://github.com/grafana/k6/pull/3831), [#3862](https://github.com/grafana/k6/pull/3862) Refactoring and cleanup around ESM PR. - [browser#1389](https://github.com/grafana/xk6-browser/pull/1389) Move deserialization of `BrowserContextOptions` into mapping layer. - https://github.com/grafana/k6/pull/3841 From 72c1cc764dbc8d585e724961de22c8fce88fb7e7 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Tue, 30 Jul 2024 15:15:02 +0300 Subject: [PATCH 12/24] Update release notes/v0.53.0.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joan Lรณpez de la Franca Beltran <5459617+joanlopez@users.noreply.github.com> --- release notes/v0.53.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index d855d3dcdb0..a505e6ea694 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -50,7 +50,7 @@ In this example when `require` is called in `/A/a.js` the `main.js` is once agai Date: Mon, 5 Aug 2024 10:28:00 +0300 Subject: [PATCH 13/24] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joan Lรณpez de la Franca Beltran <5459617+joanlopez@users.noreply.github.com> --- release notes/v0.53.0.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index a505e6ea694..e76d0ab0c22 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -179,7 +179,7 @@ But also faster startup times, more consistent errors and easier addition of fea
History of compatibility mode and ECMAScript specification compliance -Some history: More than 6 years go k6 started using core-js and babel to get ES6+ features. core-js is implementation of a lot of the types and their features such as [`String.prototype.matchAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) among other things, and Babel gets one piece of code that uses some syntax and returns a piece of code doing the same thing (mostly) but with different syntax. Usually with the idea of supporting newer syntax but returning code that can run on runtimes which only support old syntax. +Some history: More than 6 years ago k6 started using core-js and babel to get ES6+ features. core-js is a implementation of a lot of the types and their features such as [`String.prototype.matchAll`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/matchAll) among other things, and Babel gets one piece of code that uses some syntax and returns a piece of code doing the same thing (mostly) but with different syntax. Usually with the idea of supporting newer syntax but returning code that can run on runtimes which only support old syntax. This is great, but it means that: 1. For core-js each VU needs to run a bunch of JS code each initialization so it can polyfill everything that is missing @@ -195,7 +195,7 @@ At the same time the author and maintainer of the JS runtime we used (goja) did With this in mind we did try to cut down Babel as well and contribute back the simpler things it was used for. This over the years lead to small pieces of what Babel did being moved to goja and then disabled in Babel. Some of those were just easy wins, some of those were things that had very bad pathological cases where using a particular syntax made transpilation times explode. -In all of that work there always were small (or not so small) breaking changes due to many factors - sometimes our new implementation was slightly wrong and we needed to fix, sometimes more than what was in the standard was enabled in core-js or Babel, sometimes hthe standard changed on those. And sometimes the implementation in Babel or core-js wasn't as full and didn't account for all corner cases. +In all of that work there always were small (or not so small) breaking changes due to many factors - sometimes our new implementation was slightly wrong and we needed to fix, sometimes more than what was in the standard was enabled in core-js or Babel, sometimes the standard changed on those. And sometimes the implementation in Babel or core-js wasn't as full and didn't account for all corner cases. ECMAScript Modules(ESM) is the last such feature that Babel was used for. It also happens to be likely the one *most* people used, due to the fact that it is the standard way to reuse code and import libraries. From e975641d5e530a7c36e989cdde41587a3323cb31 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 5 Aug 2024 11:40:31 +0300 Subject: [PATCH 14/24] typo --- release notes/v0.53.0.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index e76d0ab0c22..ed55773816f 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -19,7 +19,8 @@ This also aligns with how ESM and dynamic `import` also work. In order to align There was a warning message for the last 2 releases trying to tease out cases where that would be problematic.
- "root of exeuction" explanation + "root of execution" explanation + This is very much an implementation detail that has leaked and likely a not intended one. Whenever a file is `require`-ed it become the "root of execution" and both `require` and `open` become relative to it. Once the `require` finishes, the previous "root of execution" gets restored. During not init context execution, the main file is the "root of execution". From 8122e44f6b02ab226f6473755975d3c00364bd78 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 5 Aug 2024 11:41:17 +0300 Subject: [PATCH 15/24] Fill small items --- release notes/v0.53.0.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index ed55773816f..ce7d63185c9 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -233,11 +233,11 @@ If you have any feedback or issues, please let us know directly in [the extensio ## UX improvements and enhancements - [#3783](https://github.com/grafana/k6/pull/3783) Set correct exit code on invalid configurations. Thank you @ariasmn! -- https://github.com/grafana/k6/pull/3868 +- [#3686](https://github.com/grafana/k6/pull/3868) Adjust logging of the executor lack of work. Thank you @athishaves! ## Bug fixes -- https://github.com/grafana/k6/pull/3746 +- [#3746](https://github.com/grafana/k6/pull/3746) Fix tags for metrics from gRPC streams. Thank you @cchamplin! - [#3845](https://github.com/grafana/k6/pull/3845) Fix logging to file sometimes missing lines. Thank you @roobre! - [browser#1391](https://github.com/grafana/xk6-browser/pull/1391) Fix race conditions in internal event handling. @@ -247,10 +247,10 @@ If you have any feedback or issues, please let us know directly in [the extensio - [#3815](https://github.com/grafana/k6/pull/3815), [#3840](https://github.com/grafana/k6/pull/3840), [#3821](https://github.com/grafana/k6/pull/3821), [#3836](https://github.com/grafana/k6/pull/3836), [#3840](https://github.com/grafana/k6/pull/3840), [#3844](https://github.com/grafana/k6/pull/3844), [#3821](https://github.com/grafana/k6/pull/3821) Update dependencies. - [#3830](https://github.com/grafana/k6/pull/3830), [#3831](https://github.com/grafana/k6/pull/3831), [#3862](https://github.com/grafana/k6/pull/3862) Refactoring and cleanup around ESM PR. - [browser#1389](https://github.com/grafana/xk6-browser/pull/1389) Move deserialization of `BrowserContextOptions` into mapping layer. -- https://github.com/grafana/k6/pull/3841 -- https://github.com/grafana/k6/pull/3837 + https://github.com/grafana/k6/pull/3847 -- https://github.com/grafana/k6/pull/3870 -- https://github.com/grafana/k6/pull/3851 +- [#3841](https://github.com/grafana/k6/pull/3841) Add browser and cloud support information to the README. Thank you @sniku! +- [#3843](https://github.com/grafana/k6/pull/3837), [#3847](https://github.com/grafana/k6/pull/3847) `k6/experimental/timers` deprecation warning updates. +- [#3851](https://github.com/grafana/k6/pull/3851) Simplify gRPC streams metrics tags tests. +- [#3870](https://github.com/grafana/k6/pull/3870) Update tests to work with go1.22. ## _Optional_ Roadmap From d0fba326990b99bf83d4c05f21153edae02a5d9b Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:50:47 +0300 Subject: [PATCH 16/24] Update release notes/v0.53.0.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joan Lรณpez de la Franca Beltran <5459617+joanlopez@users.noreply.github.com> --- release notes/v0.53.0.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index ce7d63185c9..cd538cb67f8 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -212,7 +212,9 @@ For the purposes of having less intrusive changes and shipping this earlier a fe ### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) -// TODO +In order to support the default `WebSocket.binaryType` type as per spec (`"blob"`), we have added support for the [`Blob` interface](https://developer.mozilla.org/en-US/docs/Web/API/Blob) as part of the features included in the `xk6-websockets` module. + +So, from now on it can be used with `import { Blob } from "k6/experimental/websockets";`. In the future, apart from graduating this module to stable, we might also want to expose the `Blob` interface globally (no imports will be required). But for now, please remind that its support is still experimental, as the entire module is. ### Experimental OpenTelemetry Output [#3834](https://github.com/grafana/k6/pull/3834) From 6e306f604479739e4cec73e7c723d7bed41e89a4 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Tue, 6 Aug 2024 19:37:47 +0300 Subject: [PATCH 17/24] Update release notes/v0.53.0.md Co-authored-by: Heitor Tashiro Sergent --- release notes/v0.53.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index cd538cb67f8..397ff847895 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -49,7 +49,7 @@ module.exports = 5 ``` In this example when `require` is called in `/A/a.js` the `main.js` is once again the "root of execution". If you call the function in `/A/a.js` just after defining it though, it will work as expected. -
In order to facilitate being able to write helpers that use `require` (or [dynamic import](https://github.com/grafana/k6/issues/3859) and `open` in the future) there is currently [a proposal](https://github.com/grafana/k6/issues/3856) to add `import.meta.resolve` to k6. From 23c3a0a3c376773c43aa7c7d8d2a9671ddcffdc4 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:35:45 +0300 Subject: [PATCH 18/24] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joan Lรณpez de la Franca Beltran <5459617+joanlopez@users.noreply.github.com> --- release notes/v0.53.0.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 397ff847895..65f66f576a4 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -230,7 +230,11 @@ If you have any feedback or issues, please let us know directly in [the extensio ### Consolidating cloud features under `k6 cloud` [#3813](https://github.com/grafana/k6/pull/3813) -// TODO +This release introduces the first iteration of the revamped cloud-related commands under the `k6 cloud` command, featuring two new subcommands: + +- `k6 cloud login`: replaces `k6 login cloud` for authenticating with the cloud service. It supports token-based authentication only. The previous authentication method using email and password will still be available through the legacy `k6 login cloud` command, which is now deprecated and will be removed in a future release (no removal date set yet). + +- `k6 cloud run`: is the new official way to run k6 on the cloud service, serving as an alternative to the existing `k6 cloud` command. The `k6 cloud` command will remain available for a few more versions but will eventually function only as a wrapper for all cloud-related commands, without any direct functionality. ## UX improvements and enhancements From f5bd97f90e5b3f196eaaa7cf3f9d71268edb1f7c Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 12 Aug 2024 17:08:44 +0300 Subject: [PATCH 19/24] Add import.meta.resolve --- release notes/v0.53.0.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 65f66f576a4..cead9b6b636 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -39,7 +39,7 @@ module.exports.default = () =>{} // just for k6 to not error /A/a.js: ```javascript -module.exports = function () { +module.exports = function () { return require("./b.js"); } ``` @@ -51,7 +51,7 @@ In this example when `require` is called in `/A/a.js` the `main.js` is once agai
-In order to facilitate being able to write helpers that use `require` (or [dynamic import](https://github.com/grafana/k6/issues/3859) and `open` in the future) there is currently [a proposal](https://github.com/grafana/k6/issues/3856) to add `import.meta.resolve` to k6. +You might want to use the newly added `import.meta.resolve()` if you want to create a path that is relevant to the currently calling module. This will let you call it outside a helper class and provide the path to it. ### ECMAScript Modules(ESM) Native Support related breaking changes: @@ -210,6 +210,16 @@ After ESM now being natively supported, compatibility-mode `base` vs `extended` For the purposes of having less intrusive changes and shipping this earlier a few things have not been implemented in k6. That includes top-level-await and dynamic import support. Both of them are likely to land in the next version. +### `import.meta.resolve()` get URL from a relative path the same way `import` or `require` does [#3873](https://github.com/grafana/k6/pull/3873) + +As part of the move to ESM a lot of cases where k6 currently do not resolve the same relative path to the same file were found. Some of those were fixed - as those in `require`, but others haven't. + +It also became apparent some users do use the relativity of `require`, but also `open`. As we move to make this consistent among uses, we decided to let users have a better transition path forward. + +Using `import.meta.resolve` will give you just a new URL that can be used in all functions and it will give you the same result. + +`import.meta.resolve` uses the same algorithm and relativity as ESM import syntax. + ### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) In order to support the default `WebSocket.binaryType` type as per spec (`"blob"`), we have added support for the [`Blob` interface](https://developer.mozilla.org/en-US/docs/Web/API/Blob) as part of the features included in the `xk6-websockets` module. @@ -260,7 +270,7 @@ This release introduces the first iteration of the revamped cloud-related comman ## _Optional_ Roadmap -// TODO: top-level-await, dynamic import, import.meta.resolve, `global` and compatibility-mode?!? +// TODO: top-level-await, dynamic import, `global` and compatibility-mode?!? ### Future breaking changes From 0683893f0173a69cfb703f1cbd13cf47fed4a912 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 12 Aug 2024 17:15:17 +0300 Subject: [PATCH 20/24] Add more planned breaking changes --- release notes/v0.53.0.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index cead9b6b636..9e1e8e6f34e 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -278,6 +278,18 @@ This release introduces the first iteration of the revamped cloud-related comman In the previous release, the browser module graduated from experimental to stable. The `k6/experimental/browser` module will be removed in `v0.54.0`. To keep your scripts working you need to [migrate to the `k6/browser` module](https://grafana.com/docs/k6/latest/using-k6-browser/migrating-to-k6-v0-52/). +#### Experimental timers module removal + +The experimental timers module has been deprecated for a few versions. It both has a stable import path `k6/timers`, but also all of it's current exports are available globally. + +In the next version `v0.54.0` the experimental timers module will be removed. + +#### Experimental tracing module removal + +The experimental tracing module is deprecated in this version. In two versions(`v0.55.0`) the experimental module will be removed. + +To keep your scripts working you need to [migrate to http-instrumentation-tempo jslib](https://grafana.com/docs/k6/latest/javascript-api/jslib/http-instrumentation-tempo/#migration-from-k6experimentaltracing). + #### StatsD removal In this release, we also fixed the version where we will remove the StatsD output. The StatsD output [is going to be removed in the `v0.55.0`](https://github.com/grafana/k6/pull/3849) release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). From f518631aff7e2d4501cea87737e2da2ba5419164 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 12 Aug 2024 17:15:42 +0300 Subject: [PATCH 21/24] drop emojis --- release notes/v0.53.0.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 9e1e8e6f34e..b4aa2efcbbe 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -1,10 +1,10 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: -- Native ECMAScript modules support :tada:! -- New experimental OpenTelemetry metrics output :rocket:! +- Native ECMAScript modules support +- New experimental OpenTelemetry metrics output - Blob support in experimental websockets module -- Consolidating cloud features and commands under `k6 cloud` :cloud: -- Breaking change: remove magic URL resolutions :stop_sign: +- Consolidating cloud features and commands under `k6 cloud` +- Breaking change: remove magic URL resolutions ## Breaking changes From 037573da9b5420cac01b1a19729b061346df09bb Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:39:48 +0300 Subject: [PATCH 22/24] Apply suggestions from code review Co-authored-by: Heitor Tashiro Sergent --- release notes/v0.53.0.md | 54 +++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index b4aa2efcbbe..5d4d48a7623 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -3,16 +3,16 @@ k6 `v0.53.0` is here ๐ŸŽ‰! This release includes: - Native ECMAScript modules support - New experimental OpenTelemetry metrics output - Blob support in experimental websockets module -- Consolidating cloud features and commands under `k6 cloud` +- Consolidate cloud features and commands under `k6 cloud` - Breaking change: remove magic URL resolutions ## Breaking changes -### Require is now specification compliant and always resolve based on the file it is written in [#3534](https://github.com/grafana/k6/issues/3534) +### Require is now specification compliant and always resolves based on the file it is written in [#3534](https://github.com/grafana/k6/issues/3534) -`require` in k6 used to resolve identifiers based on the current "root of execution" (more on that later). In a lot of cases that aligns with the file the `require` is written in or a file in the same folder, which leads to the same result. In a small subset of cases, this isn't the case. +The `require` function in k6 used to resolve identifiers based on the current "root of execution" (more on that later). In a lot of cases, that aligns with the file the `require` is written in or a file in the same folder, which leads to the same result. In a small subset of cases, this isn't the case. -Every other implementation and more or less by the CommonJS specification - require should always be relative to the file it is written in. +In every other implementation, and more or less by the CommonJS specification, `require` should always be relative to the file it is written in. This also aligns with how ESM and dynamic `import` also work. In order to align with them `require` now uses the same underlying implementation. @@ -23,7 +23,7 @@ There was a warning message for the last 2 releases trying to tease out cases wh This is very much an implementation detail that has leaked and likely a not intended one. -Whenever a file is `require`-ed it become the "root of execution" and both `require` and `open` become relative to it. Once the `require` finishes, the previous "root of execution" gets restored. During not init context execution, the main file is the "root of execution". +Whenever a file is `require`-ed it becomes the "root of execution", and both `require` and `open` become relative to it. Once the `require` finishes, the previous "root of execution" gets restored. During the `init` context execution, the main file is the "root of execution". Example: @@ -51,11 +51,11 @@ In this example when `require` is called in `/A/a.js` the `main.js` is once agai -You might want to use the newly added `import.meta.resolve()` if you want to create a path that is relevant to the currently calling module. This will let you call it outside a helper class and provide the path to it. +You can use the newly added `import.meta.resolve()` function if you want to create a path that is relevant to the currently calling module. That will let you call it outside of a helper class and provide the path to it. Refer to [docs](https://grafana.com/docs/k6/next/javascript-api/import.meta/resolve/) for more details. -### ECMAScript Modules(ESM) Native Support related breaking changes: +### ECMAScript Modules (ESM) Native Support related breaking changes -As part of the implementation, two common patterns broken in the ecosystem became apparent. +As part of the ESM native support implementation, two common broken patterns in the ecosystem became apparent. One is arguably a developer experience improvement, and the other is a consequence of the previous implementation. @@ -65,7 +65,7 @@ Previously, k6 used a transpiler (Babel) internally to transpile ESM syntax to C As k6 (or the underlying JS VM implementation) did not understand ESM in itself and that CommonJS is a 100% during execution feature, this was not easy to detect or prevent. -We added a [warning](https://github.com/grafana/k6/pull/3807) in v0.52.0 to give users time for migration. +We added a [warning](https://github.com/grafana/k6/pull/3807) in v0.52.0 to give users time for migration. To fix this - all you need is to stick to either CommonJS or ESM within each file. @@ -80,23 +80,25 @@ module.exports.default = func() { ...} In the example above both ESM and CommonJS are used in the same file. -Either replace +You can either replace: + ```javascript module.exports.default = func() {} ``` -with the ESM syntax +With the ESM syntax: ```javascript export default func() {} ``` -or replace +Or replace: ```javascript import { sleep } from "k6"; ``` - with the CommonJS: + +With CommonJS: ```javascript const sleep = require("k6").sleep; @@ -106,21 +108,22 @@ const sleep = require("k6").sleep; #### Imported identifier that can't be resolved are now errors -Previously to this if you were using the ESM syntax but imported identifier `foo` but the exporting file didn't export it - there will be no error. +Previous to this, if you were using the ESM syntax and imported the `foo` identifier, but the exporting file didn't export it, there wouldn't be an error. bar.js: ```javascript export const notfoo = 5; ``` -main.js +main.js ```javascript import { foo } from "./bar.js" export default function () { foo.bar(); // throws exception here } ``` -It would not error out, but when it is accessed, there will be an exception as it will be `undefined`. + +The example would not error out, but when it is accessed, there would be an exception as `foo` would be `undefined`. With native ESM support, that is an error as defined by the specification and will occur sooner. @@ -132,13 +135,14 @@ The solution, in this case, is to stop importing the not exported identifiers. For a long time, k6 has supported special _magic_ URLs that aren't really that. -Those were URLs without a scheme, that: -1. started with `github.com` that if pasted in a browser will not open you the file. Their appeal was that you can more easily write them by hand if you know the path within a github repo. -2. started with `cdnjs.com` that if pasted in a browser will open an web page with all the versions of the library. The appeal here is that you will get the latest version. +Those were URLs without a scheme that: + +1. Started with `github.com`, and if pasted to a browser won't open to a file. Their appeal was that you can more easily write them by hand if you know the path within a GitHub repo. +2. Started with `cdnjs.com`, and if pasted to a browser will open a web page with all the versions of the library. The appeal here is that you will get the latest version. Both of them had problems though. -The github ones seemed to have never be used by users, likely because you need to guess what the path should look like, and you can always just go get a real URL to the raw file. +The GitHub ones seemed to have never been used by users, likely because you need to guess what the path should look like, and you can always just go get a real URL to the raw file. While the cdnjs ones have some more usage, they are both a lot more complicated to support, as they require multiple requests to figure out what needs to be loaded. They also change over time. In addition the only known use at the moment is based on a very old example from an issue and it is even pointing to concrete, old version, of a library. @@ -146,7 +150,7 @@ Given that this can be done with a normal URL, we have decided to drop support f ### Deprecated `k6/experimental/tracing` in favor of a JavaScript implementation -`k6/experimental/tracing` is arguably not very well named, and there is good chances we would like to use the name for actual trace and span support within k6 in the future. +`k6/experimental/tracing` is arguably not very well named, and there is a good chance we would like to use the name for actual trace and span support within k6 in the future. On top of that it can now be fully supported in js code, which is why [http-instrumentation-tempo ](https://grafana.com/docs/k6/latest/javascript-api/jslib/http-instrumentation-tempo/) was created. @@ -210,7 +214,7 @@ After ESM now being natively supported, compatibility-mode `base` vs `extended` For the purposes of having less intrusive changes and shipping this earlier a few things have not been implemented in k6. That includes top-level-await and dynamic import support. Both of them are likely to land in the next version. -### `import.meta.resolve()` get URL from a relative path the same way `import` or `require` does [#3873](https://github.com/grafana/k6/pull/3873) +### `import.meta.resolve()` gets an URL from a relative path the same way `import` or `require` does [#3873](https://github.com/grafana/k6/pull/3873) As part of the move to ESM a lot of cases where k6 currently do not resolve the same relative path to the same file were found. Some of those were fixed - as those in `require`, but others haven't. @@ -218,17 +222,17 @@ It also became apparent some users do use the relativity of `require`, but also Using `import.meta.resolve` will give you just a new URL that can be used in all functions and it will give you the same result. -`import.meta.resolve` uses the same algorithm and relativity as ESM import syntax. +`import.meta.resolve` uses the same algorithm and relativity as ESM import syntax. Refer to [docs](https://grafana.com/docs/k6/next/javascript-api/import.meta/resolve/) for more details. ### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) In order to support the default `WebSocket.binaryType` type as per spec (`"blob"`), we have added support for the [`Blob` interface](https://developer.mozilla.org/en-US/docs/Web/API/Blob) as part of the features included in the `xk6-websockets` module. -So, from now on it can be used with `import { Blob } from "k6/experimental/websockets";`. In the future, apart from graduating this module to stable, we might also want to expose the `Blob` interface globally (no imports will be required). But for now, please remind that its support is still experimental, as the entire module is. +So, from now on it can be used with `import { Blob } from "k6/experimental/websockets";`. In the future, apart from graduating this module to stable, we might also want to expose the `Blob` interface globally (no imports will be required). But for now, please remind that its support is still experimental, as the entire module is. Refer to the [docs](https://grafana.com/docs/k6/next/javascript-api/k6-experimental/websockets/blob/) for more details. ### Experimental OpenTelemetry Output [#3834](https://github.com/grafana/k6/pull/3834) -This release introduces a new experimental output for OpenTelemetry. This allows users to send k6 metrics to any OpenTelemetry-compatible backends. More details and usage examples could be found in the [documentation](https://grafana.com/docs/k6/latest/results-output/real-time/opentelemetry/). +This release introduces a new experimental output for OpenTelemetry. This allows users to send k6 metrics to any OpenTelemetry-compatible backends. More details and usage examples can be found in the [documentation](https://grafana.com/docs/k6/latest/results-output/real-time/opentelemetry/). To output metrics to OpenTelemetry, use the `experimental-opentelemetry` output option: From b622003a35d1c4431b4eb59d52210939561f2f11 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> Date: Tue, 13 Aug 2024 10:42:10 +0300 Subject: [PATCH 23/24] Apply suggestions from code review --- release notes/v0.53.0.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 5d4d48a7623..40094c7058b 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -23,7 +23,7 @@ There was a warning message for the last 2 releases trying to tease out cases wh This is very much an implementation detail that has leaked and likely a not intended one. -Whenever a file is `require`-ed it becomes the "root of execution", and both `require` and `open` become relative to it. Once the `require` finishes, the previous "root of execution" gets restored. During the `init` context execution, the main file is the "root of execution". +Whenever a file is `require`-ed it becomes the "root of execution", and both `require` and `open` become relative to it. Once the `require` finishes, the previous "root of execution" gets restored. Outside of the `init` context execution, the main file is the "root of execution". Example: @@ -51,7 +51,7 @@ In this example when `require` is called in `/A/a.js` the `main.js` is once agai -You can use the newly added `import.meta.resolve()` function if you want to create a path that is relevant to the currently calling module. That will let you call it outside of a helper class and provide the path to it. Refer to [docs](https://grafana.com/docs/k6/next/javascript-api/import.meta/resolve/) for more details. +You can use the newly added `import.meta.resolve()` function if you want to create a path that is relevant to the currently calling module. That will let you call it outside of a helper class and provide the path to it. Refer to [docs](https://grafana.com/docs/k6/latest/javascript-api/import.meta/resolve/) for more details. ### ECMAScript Modules (ESM) Native Support related breaking changes @@ -222,13 +222,13 @@ It also became apparent some users do use the relativity of `require`, but also Using `import.meta.resolve` will give you just a new URL that can be used in all functions and it will give you the same result. -`import.meta.resolve` uses the same algorithm and relativity as ESM import syntax. Refer to [docs](https://grafana.com/docs/k6/next/javascript-api/import.meta/resolve/) for more details. +`import.meta.resolve` uses the same algorithm and relativity as ESM import syntax. Refer to [docs](https://grafana.com/docs/k6/latest/javascript-api/import.meta/resolve/) for more details. ### Blob support in the experimental websockets module [grafana/xk6-websockets#74](https://github.com/grafana/xk6-websockets/pull/74) In order to support the default `WebSocket.binaryType` type as per spec (`"blob"`), we have added support for the [`Blob` interface](https://developer.mozilla.org/en-US/docs/Web/API/Blob) as part of the features included in the `xk6-websockets` module. -So, from now on it can be used with `import { Blob } from "k6/experimental/websockets";`. In the future, apart from graduating this module to stable, we might also want to expose the `Blob` interface globally (no imports will be required). But for now, please remind that its support is still experimental, as the entire module is. Refer to the [docs](https://grafana.com/docs/k6/next/javascript-api/k6-experimental/websockets/blob/) for more details. +So, from now on it can be used with `import { Blob } from "k6/experimental/websockets";`. In the future, apart from graduating this module to stable, we might also want to expose the `Blob` interface globally (no imports will be required). But for now, please remind that its support is still experimental, as the entire module is. Refer to the [docs](https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/websockets/blob/) for more details. ### Experimental OpenTelemetry Output [#3834](https://github.com/grafana/k6/pull/3834) @@ -273,8 +273,7 @@ This release introduces the first iteration of the revamped cloud-related comman - [#3870](https://github.com/grafana/k6/pull/3870) Update tests to work with go1.22. -## _Optional_ Roadmap -// TODO: top-level-await, dynamic import, `global` and compatibility-mode?!? +## Roadmap ### Future breaking changes From 914de4a730fcdf01f8c3a3db1bf53332c70b920e Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Mon, 12 Aug 2024 19:03:32 +0300 Subject: [PATCH 24/24] global in compatibility-mode note --- release notes/v0.53.0.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/release notes/v0.53.0.md b/release notes/v0.53.0.md index 40094c7058b..63a56bacf17 100644 --- a/release notes/v0.53.0.md +++ b/release notes/v0.53.0.md @@ -296,3 +296,9 @@ To keep your scripts working you need to [migrate to http-instrumentation-tempo #### StatsD removal In this release, we also fixed the version where we will remove the StatsD output. The StatsD output [is going to be removed in the `v0.55.0`](https://github.com/grafana/k6/pull/3849) release. If you are using the StatsD output, please consider migrating to the extension [LeonAdato/xk6-output-statsd](https://github.com/LeonAdato/xk6-output-statsd). + +#### Potentially dropping `global` from `extended` compatibility-mode + +Currently `global` is aliased to `globalThis` when `extended` compatibility-mode is used. This is currently the only difference with the `base` compatibility-mode. + +Given that this seems to have very low usage it might be dropped in the future. See the [issue](https://github.com/grafana/k6/issues/3864) for more info or if you want to comment on this.