-
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
Update Sobek and fix http.File to not use []byte #4009
Conversation
Sobek updates bring fixes from goja for: - nesting of destructuring with arrays - using slices from go code in js code Also fix for async errors in modules triggering the promise rejection tracker as well, which will be needed for top-level-await The changes to handling of slices did break some tests and showcased that k6 was handling `http.File().data` badly. Previously it was `[]byte` which it really shouldn't be. This fix makes certain that the provided input is `string` or `ArrayBuffer` and keeps it that way until it needs to be written. This aligns with the documentation as well as removes a source of pure `[]byte` in js code which there shouldn't be any. Separate PR should be made to drop being able to use `common.ToBytes` with `[]byte` as that should never happen and should be 100% a bug. Also made the go code return a pointer as that just makes sense instead of a struct that will get copied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers for the detailled explanation 🙇🏻
* Initialize v0.55.0 release notes * Update release notes for browser 1448 * Update release notes for browser page.on generalization * Update release notes for browser 1439 * Update release notes for browser 1461 * Update release notes for browser 1496 I'm not yet sure if we should add this PR as it's a part of a bigger functionality that we expect to have in k6 v0.56. See the issue for more details: /~https://github.com/grafana/xk6-browser/issues/1289 * Replace issue 1461 with PR 1462 * release notes: webcrypto RSA support * release notes: statsd output removal * release notes: outputs changes * Add browser related changes to release notes * Remove template examples from release notes * Add browser#1457 to release notes * release notes: updates check recommendation * Add initial page.on('metric') release note change * Add issues to the page.on('metric') release note * release notes: add TLA support section * release notes: add tracing breaking change and future open ones * auto-assigner changelog * check recommendation apply feedback * fixup! release notes: add tracing breaking change and future open ones * Apply release notes clean-ups and fillers * Address wrong formulation of tracing removal * Update release notes/v0.55.0.md Co-authored-by: Oleg Bespalov <oleg.bespalov@grafana.com> * Apply suggestions from code review Co-authored-by: Ankur <ankur.agarwal@grafana.com> * Apply suggestions from code review Co-authored-by: Ankur <ankur.agarwal@grafana.com> * Apply pull request review suggestions * Update the page.on('metric') description * Update release notes/v0.55.0.md Co-authored-by: Ankur <ankur.agarwal@grafana.com> * Update page.on example as an expandable detail * Align last sections format with template * Update ControlOrMeta description * Update wording of page.on example * Apply pull request review suggestions * Document #4017 bug fix * Update release notes/v0.55.0.md Co-authored-by: Mihail Stoykov <312246+mstoykov@users.noreply.github.com> * Bring minor improvement to #4009 --------- Co-authored-by: İnanç Gümüş <inanc.gumus@grafana.com> Co-authored-by: Oleg Bespalov <oleg.bespalov@grafana.com> Co-authored-by: ankur22 <ankur.agarwal@grafana.com> Co-authored-by: Mihail Stoykov <M.Stoikov@gmail.com> Co-authored-by: Mihail Stoykov <312246+mstoykov@users.noreply.github.com>
import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js' Let documentFile = http.get( ) const fd = new FormData(); let response = http.put(, fd.body(), {headers: {Content-Type': 'multipart/form-data; boundary=' + fd.boundary}}) The documentFile.body is fetched from the first API, then passed as a file using http.file() in the FormData for the second API request. While this approach works as expected in the open-source k6 environment, it fails in Grafana Cloud with the error message indicating that the document file appears corrupted and cannot be loaded. Error: {"statusCode":406,"error":"Not Acceptable","message":"The document appears to be corrupted and cannot be loaded."} It appears that there may be a discrepancy in how file uploads are handled between the open-source version of k6 and Grafana Cloud, particularly after the recent release. Any guidance or updates regarding this issue would be greatly appreciated. |
@manjunadh5369 does it work locally with the latest k6 version v0.55.0 ? |
@mstoykov Oh, I just verified that my local k6 version was not upgraded as I initially thought—it’s still running on v0.51.0. I’ve since upgraded it to the latest version, v0.55.0, and unfortunately, the issue persists locally as well. Could you please assist me with steps or guidance on how to make this work as it did with the older version? Any help would be greatly appreciated! |
My expectation is that if you set the response to be binary on the request getting the document it will work again. Can you try it? You need to set the request params to have |
Thank you very much @mstoykov! It's working now. |
Glad I could help. To be honest I expect that before that thsi request was jsut a touch corrupted as going to string and back to binary as you did before this last change likely broke the file underneed. I guess your API either doesn't check the send API that carefully, you were very lucky for the transition to be lossless, or the response is actually text and your API just expects it as binary data for some reason. |
What?
Update Sobek
Why?
Sobek updates bring fixes from goja for:
Also fix for async errors in modules triggering the promise rejection tracker as well, which will be needed for top-level-await
The changes to handling of slices did break some tests and showcased that k6 was handling
http.File().data
badly. Previously it was[]byte
which it really shouldn't be.This fix makes certain that the provided input is
string
orArrayBuffer
and keeps it that way until it needs to be written.This aligns with the documentation as well as removes a source of pure
[]byte
in js code which there shouldn't be any.Separate PR should be made to drop being able to use
common.ToBytes
with[]byte
as that should never happen and should be 100% a bug.Also made the go code return a pointer as that just makes sense instead of a struct that will get copied.
Checklist
make lint
) and all checks pass.make tests
) and all tests pass.Related PR(s)/Issue(s)