Expected Behavior
A pre-request script copied from a working Postman request should execute successfully within Insomnia's time limit. After the script completes, the main HTTP request should be sent as configured.
Actual Behavior
When I copy a pre-request script directly from Postman and paste it into Insomnia's "Pre-Request" script editor, the request execution hangs and eventually results in a timeout error. The main HTTP request is never sent. The exact same script works perfectly and executes quickly in Postman.
Reproduction Steps
Create a request in Postman with a functional pre-request script blow.
Copy the entire content of the Postman pre-request script.
In Insomnia, create a new HTTP request.
Navigate to the Script tab and select the pre Request section.
Paste the script copied from Postman into the editor.
Click "Send" to execute the request.
Observe that the request loading indicator runs indefinitely until a timeout error is displayed.
postman pre-script:
console.log('Pre-request Script from Request start');
if (pm.request.method !== 'GET' && !(pm.request.headers.has('x-csrf-token'))) {
var csrfRequest = pm.request.clone();
csrfRequest.method = 'GET';
if (pm.request.method === 'POST') {
csrfRequest.url = pm.request.url + '?$top=1';
}
csrfRequest.upsertHeader({
key: 'x-csrf-token',
value: 'fetch'
});
pm.sendRequest(csrfRequest, function(err, res) {
console.log('pm.sendRequest start');
if (err) {
console.log(err);
} else {
var csrfToken = res.headers.get('x-csrf-token');
if (csrfToken) {
console.log('csrfToken fetched:' + csrfToken);
pm.request.headers.upsert({
key: 'x-csrf-token',
value: csrfToken
});
} else {
console.log('No csrf token fetched');
}
}
console.log('pm.sendRequest end');
});
}
console.log('Pre-request Script from Request end');
COPY TO postman
console.log('Pre-request Script from Request start');
if (insomnia.request.method !== 'GET' && !(insomnia.request.headers.has('x-csrf-token'))) {
var csrfRequest = insomnia.request.clone();
csrfRequest.method = 'GET';
if (insomnia.request.method === 'POST') {
csrfRequest.url = insomnia.request.url + '?$top=1';
}
csrfRequest.upsertHeader({
key: 'x-csrf-token',
value: 'fetch'
});
insomnia.sendRequest(csrfRequest, function(err, res) {
console.log('insomnia.sendRequest start');
if (err) {
console.log(err);
} else {
var csrfToken = res.headers.get('x-csrf-token');
if (csrfToken) {
console.log('csrfToken fetched:' + csrfToken);
insomnia.request.headers.upsert({
key: 'x-csrf-token',
value: csrfToken
});
} else {
console.log('No csrf token fetched');
}
}
console.log('insomnia.sendRequest end');
});
}
console.log('Pre-request Script from Request end');
Is there an existing issue for this?
Which sync method do you use?
Additional Information
No response
Insomnia Version
11.4.0
What operating system are you using?
Windows
Operating System Version
WIN11 23H2 22631.5768
Installation method
GITHUB Insomnia.Core-11.4.0.exe
Last Known Working Insomnia version
No response
Expected Behavior
A pre-request script copied from a working Postman request should execute successfully within Insomnia's time limit. After the script completes, the main HTTP request should be sent as configured.
Actual Behavior
When I copy a pre-request script directly from Postman and paste it into Insomnia's "Pre-Request" script editor, the request execution hangs and eventually results in a timeout error. The main HTTP request is never sent. The exact same script works perfectly and executes quickly in Postman.
Reproduction Steps
Create a request in Postman with a functional pre-request script blow.
Copy the entire content of the Postman pre-request script.
In Insomnia, create a new HTTP request.
Navigate to the Script tab and select the pre Request section.
Paste the script copied from Postman into the editor.
Click "Send" to execute the request.
Observe that the request loading indicator runs indefinitely until a timeout error is displayed.
postman pre-script:
COPY TO postman
Is there an existing issue for this?
Which sync method do you use?
Additional Information
No response
Insomnia Version
11.4.0
What operating system are you using?
Windows
Operating System Version
WIN11 23H2 22631.5768
Installation method
GITHUB Insomnia.Core-11.4.0.exe
Last Known Working Insomnia version
No response