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

fix: avoid rendering script by temporarily disable it #7466

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ resources:
insomnia.environment.set('__fromAfterScript', 'environment');
insomnia.baseEnvironment.set('__fromAfterScript1', 'baseEnvironment');
insomnia.collectionVariables.set('__fromAfterScript2', 'collection');
insomnia.environment.replaceIn('{{ $timestamp }}');
body:
mimeType: "application/json"
text: |-
Expand Down
7 changes: 7 additions & 0 deletions packages/insomnia/src/ui/routes/request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ export const sendAction: ActionFunction = async ({ request, params }) => {
if (mutatedContext === null) {
return null;
}
// disable after-response script here to avoiding rendering it
const afterResponseScript = `${mutatedContext.request.afterResponseScript}`;
mutatedContext.request.afterResponseScript = '';

const renderedResult = await tryToInterpolateRequest(
mutatedContext.request,
mutatedContext.environment,
Expand Down Expand Up @@ -407,9 +411,12 @@ export const sendAction: ActionFunction = async ({ request, params }) => {
const responsePatch = await responseTransform(response, requestData.activeEnvironmentId, renderedRequest, renderedResult.context);
const is2XXWithBodyPath = responsePatch.statusCode && responsePatch.statusCode >= 200 && responsePatch.statusCode < 300 && responsePatch.bodyPath;
const shouldWriteToFile = shouldPromptForPathAfterResponse && is2XXWithBodyPath;

mutatedContext.request.afterResponseScript = afterResponseScript;
if (requestData.request.afterResponseScript) {
const baseEnvironment = await models.environment.getOrCreateForParentId(workspaceId);
const cookieJar = await models.cookieJar.getOrCreateForParentId(workspaceId);

const postMutatedContext = await tryToExecuteAfterResponseScript({
...requestData,
...mutatedContext,
Expand Down
Loading