-
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
[FormData polyfill for k6] Method body() returns an empty object for an instance of FormData class #3677
Comments
Hi @k-kudryavtseva, I might be wrong, but at first glance, I'd suggest that the behavior you're seeing, where logging the result of In other words, Instead, I'd suggest you to actually verify if Alternatively, you could do something as below, to verify that there's something, but as the const fdBody = fd.body(); // Assuming fd.body() returns an ArrayBuffer
const typedArray = new Uint8Array(fdBody); // Create a typed array from the ArrayBuffer
// Now, you can convert this typed array to a string that can be logged.
// For example, you might convert it to a series of hexadecimal values, or directly to a string if it represents text data.
console.log(`formData.body() >>> ${JSON.stringify(Array.from(typedArray))}`); Even simpler, you could just print the length of the Please, can you confirm that's the case? Or are you actually receiving / seeing an empty payload going through network? Thanks! 🙇🏻 |
Thank you so much @joanlopez for the detailed explanation. I got the output for the body() method as you described it. The issue with the failed request in my case was related to using the wrong Auth Token. Sorry for bringing up confusion and thank you again for a quick response! |
Greetings! @joanlopez I encountered a similar issue and don't understand how to solve it. I have a .txt file with the following data:
My task is to send a POST request just like the client does. https://grafana.com/docs/k6/latest/examples/data-uploads/#advanced-multipart-request Here’s my code: export function paymentLoadEmptyFile(fullHeaders) {
} The result is that an empty object Here is what client sends |
Hi @kasianovalex, When you say "what client sends" you mean another client? |
What if you print the |
@kasianovalex Please read #3677 (comment) and follow the explaantion there on how to print the formdata body which is an ArrayBuffer |
Brief summary
When trying to upload a CSV or Txt file using the polyfill, method body() returns an empty object.
k6 version
k6 v0.50.0 (go1.22.1, darwin/arm64)
OS
macOS (Version 14.3)
Docker version and image (if applicable)
No response
Steps to reproduce the problem
`
const csvFile = open('../data/data.csv');
export function setup () {
describe("POST /", () => {
}
`
Expected behaviour
The method returns "the assembled request body as an ArrayBuffer" as noted here. The POST request succeeded.
Actual behaviour
The method body() returns an empty object (see the screenshot). The POST request failed.
The text was updated successfully, but these errors were encountered: