Skip to content

fix: empty files when saving large response bodies#10160

Open
Copilot wants to merge 4 commits into
developfrom
copilot/fix-save-to-file-empty-file
Open

fix: empty files when saving large response bodies#10160
Copilot wants to merge 4 commits into
developfrom
copilot/fix-save-to-file-empty-file

Conversation

Copilot AI commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Large responses are intentionally not kept in memory to avoid freezing the preview UI, but the existing save flow only wrote response.bodyBuffer. For responses stored on disk, that produced an empty file even though the body was available.

  • Save flow

    • Extend downloadResponseBody(...) to accept a fallback body loader.
    • Resolve the body from disk when the in-memory buffer is absent, then write the resolved bytes/string to the selected file.
    • Keep existing behavior for small responses that already have bodyBuffer populated.
  • Response pane wiring

    • Pass a filesystem-backed loader from response-pane.tsx using services.helpers.getResponseBodyBuffer(activeResponse).
    • Normalize loader results to Uint8Array | null so the save helper does not need to interpret error strings.
  • Regression coverage

    • Add focused tests for:
      • raw export when bodyBuffer is null
      • prettified JSON export when bodyBuffer is null
await downloadResponseBody(
  activeRequest,
  activeResponse,
  prettify,
  activeResponse
    ? async () => {
        const bodyBuffer = await services.helpers.getResponseBodyBuffer(activeResponse);
        return typeof bodyBuffer === 'string' ? null : bodyBuffer;
      }
    : undefined,
);

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI changed the title [WIP] Fix 'Save to File' button creating empty file Fix empty files when saving large response bodies Jun 25, 2026
Copilot AI requested a review from notjaywu June 25, 2026 03:11
@notjaywu notjaywu force-pushed the copilot/fix-save-to-file-empty-file branch from c36ffa6 to 20c84a0 Compare June 25, 2026 03:45
@notjaywu notjaywu changed the title Fix empty files when saving large response bodies fix: empty files when saving large response bodies Jun 25, 2026
@notjaywu notjaywu requested review from a team and removed request for notjaywu June 25, 2026 03:46
@notjaywu notjaywu marked this pull request as ready for review June 25, 2026 03:47
Copilot AI review requested due to automatic review settings June 25, 2026 03:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes the “empty file” regression when saving large response bodies by allowing the save helper to load the body from disk when the in-memory bodyBuffer is absent. This aligns the response save flow with the existing oversized-response storage model (bodies can live on disk via bodyPath).

Changes:

  • Extend downloadResponseBody(...) to accept an optional async body loader and use it when activeResponse.bodyBuffer is null/undefined.
  • Wire the response pane’s “download body” action to pass a loader backed by services.helpers.getResponseBodyBuffer(activeResponse).
  • Add unit tests covering raw and prettified JSON exports when bodyBuffer is null.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/insomnia/src/ui/components/panes/response-pane.tsx Passes a filesystem-backed body loader into the download helper for large/on-disk responses.
packages/insomnia/src/ui/components/panes/response-pane-utils.ts Adds loader support and writes resolved body bytes/string instead of only response.bodyBuffer.
packages/insomnia/src/ui/components/panes/tests/response-pane-utils.test.ts Adds regression tests for disk-backed body loading in both prettified JSON and raw export paths.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-06-25T03:50:14.545Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 9 9 0 (0.00%)
Click to view all circular references in PR (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

@notjaywu notjaywu removed their assignment Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants