Skip to content
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

Bruno takes 2 requests to apply the changes made by a script #2335

Open
2 tasks done
fhuertas opened this issue May 17, 2024 · 2 comments
Open
2 tasks done

Bruno takes 2 requests to apply the changes made by a script #2335

fhuertas opened this issue May 17, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@fhuertas
Copy link

I have checked the following:

  • I use the newest version of bruno.
  • I've searched existing issues and found nothing related to my issue.

Describe the bug

SO: Fedora 40

Bruno takes 2 requests to apply the changes made by a script

Step1: Configure an environment with butBody var (it doesn't work in another way)
Step2: Modify script. i.e. change bar2 to bar 3
Step3: Make a request, the server will show the following body: {"foo":"bar","foo2":"bar2"}
Step3: Make another request, the server will show the following body: {"foo":"bar","foo2":"bar3"}

.bru file to reproduce the bug

meta {
name: local
type: http
seq: 2
}

post {
url: http://localhost:8000
body: json
auth: none
}

body:json {
{{putBody}}

}

script:pre-request {

var body = {}

body.foo = "bar"
body.foo2 = "bar5"

bru.setEnvVar("putBody", JSON.stringify(body));

}

Screenshots/Live demo link

https://drive.google.com/file/d/1F4tUotrimFsV5YBcaocVxjxSIGRVzKxK/view?usp=sharing

@fhuertas fhuertas added the bug Something isn't working label May 17, 2024
@jadamik
Copy link

jadamik commented May 21, 2024

Can confirm this is happening at least since version 1.15.0. It seems like Bruno is not waiting for pre-request scripts to be completed, so if complex data generation takes place in pre-request script then variables won't be set in time for Bruno to use them on request.

@fhuertas
Copy link
Author

Hi Yes,

I have checked and it doesn't happen in version 1.14.0 but it happens in 1.15.0

Also, in 1.14.0, It is not necessary to set the environment variable putBody to setEnvVar function works

@sanjai0py sanjai0py self-assigned this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants