bruno
bruno copied to clipboard
feat: save request/response history (including between launches)
Insomnia saves all the requests that were done. This history persists even if we restart Insomnia. This is a very useful feature when you want to have a quick look at how a response body looks.
One feature that Insomnia doesn't have (but which Postman has), and is very useful, is the ability to give a name to the request/response history entry.
Also, since the requests and responses may contain sensitive data, they shouldn't be saved in the collection directory, but outside of it, only on the local machine, just as Bruno handles secret environment variables.
i need this for my current project so bad, that i gave in and signed up for insomnia. I have long running tasks that take up over 100 seconds and with bruno on error i only get a pop up that shows for 2 seconds without any real information and thats it. If i want to see it again i have to redo the request and wait again, what a bummer.
@carlonoelle
We'll support History very soon. Meanwhile I can suggest a workaround. In the v0.22.0
release, we have released support for collection level scripting. And you can log you response in the collection post script for debugging purpose.
Here is our scripting docs: https://docs.usebruno.com/scripting/javascript-reference.html
Can you check and see if this is of any help?
Thanks @helloanoop, for now that helps. That it is on the roadmap is good to know though since console is not persistent,
since console is not persistent
@carlonoelle here is one neat hack of using post response scripting in the collection level.
You just need to create a logs
directory inside your collection root folder and every request-response will get saved here.
const fs = require('fs');
const path = require('path');
const moment = require('moment');
const safeStringify = function (obj) {
try {
return JSON.stringify(obj, null, 2);
} catch (err) {
return obj
}
};
const request = {
url: req.getUrl(),
headers: req.getHeaders(),
method: req.getMethod(),
body: req.getBody()
};
const response = {
status: res.getStatus(),
headers: res.getHeaders(),
body: res.getBody()
};
const now = moment();
const formattedDate = now.format('YYYYMMDD-HHmmss');
const filename = path.join(bru.cwd(), 'logs', `${formattedDate}.json`);
const content = safeStringify({request, response}, null, 2);
fs.writeFileSync(filename, content);
You also need to add the scripts
field in your bruno.json
at the root of collection to allow fs
access
{
"scripts": {
"filesystemAccess": {
"allow": true
}
}
}
any progress?
I like the suggested work around @helloanoop but I am getting an error (on Windows) Error invoking remote method 'send-http-request': VMError: Module 'C:\Users\xxx\AppData\Local\Programs\bruno\fs' is not allowed to be required. The path is outside the border!
Nevermind, I found this info about setting bruno to allow file system access: https://github.com/usebruno/bruno/discussions/385#discussioncomment-7246390 Logging is working now :)
@testmonger Please also add the scripts
field in your bruno.json
at the root of collection to fix the filesystem issue
{
"scripts": {
"filesystemAccess": {
"allow": true
}
}
}
Any progress here? Persistent request history would be very useful.
@helloanoop @sanjai0py Is anyone working on this issue from your side? If not, could you assign this to me. I can start working on it.
@helloanoop @sanjai0py Is anyone working on this issue from your side? If not, could you assign this to me. I can start working on it.
This feature is already implemented in the Golden Edition