Skip to content

Commit

Permalink
fix: avoid rendering script by temporarily disable it
Browse files Browse the repository at this point in the history
  • Loading branch information
ihexxa committed May 30, 2024
1 parent 41c79a1 commit 8e9e209
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
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

0 comments on commit 8e9e209

Please sign in to comment.