Kong / insomnia

The open-source, cross-platform API client for GraphQL, REST, WebSockets, SSE and gRPC. With Cloud, Local and Git storage.
https://insomnia.rest
Apache License 2.0
34.51k stars 1.95k forks source link

[Feature request] Running request folder via Plugin API should show latest response data #6512

Open jreyesr opened 1 year ago

jreyesr commented 1 year ago

Expected Behavior

When a plugin triggers a request (via network.sendRequest), that response should appear on the response history dropdown, as the responses of manually-triggered requests do.

Actual Behavior

Plugin-initiated responses don't appear on the history dropdown until a request is sent manually (with the Send button), at which point all the responses that were caused by the plugin, plus the recently-made manual request, all appear at once

Reproduction Steps

  1. Install a plugin that programmatically makes requests (see on Additional information for a minimal repro). The Send Request example in the docs is enough to cause the issue
  2. Create a new request
  3. Execute the plugin on the request (via the request's context menu)
  4. The response history for the request should contain a new entry, but it doesn't. If it was the first call of the request (or the first call after clearing the history) the button for the history dropdown won't even appear (as it doesn't if there are no responses yet)
  5. Manually send the request
  6. The history button will appear and contain two entries (one for the plugin-initiated response, and one for the manual one)

Is there an existing issue for this?

Additional Information

This was reported on a Insomnia plugin that I maintain. See https://github.com/jreyesr/insomnia-plugin-batch-requests/issues/10. However, I can reproduce it with a very simple plugin too, taken directly from the docs, so it appears to be general and thus I'm reporting it here.

To reproduce the issue, you can use the following minimal plugin:

package.json ```json { "name": "insomnia-plugin-repro-history", "version": "0.0.1", "private": true, "insomnia": { "name": "repro-history", "description": "" }, "main": "main.js" } ```
main.js ```js module.exports.requestActions = [ { label: "Send request", action: async (context, data) => { const { request } = data; const response = await context.network.sendRequest(request); const html = `${request.name}: ${response.statusCode}`; context.app.showGenericModalDialog("Results", { html }); }, }, ]; ```

Insomnia Version

2023.5.8

What operating system are you using?

Windows

Operating System Version

Ubuntu 22.04

Installation method

APT (.deb file)

Last Known Working Insomnia version

2022.5.7

jreyesr commented 1 year ago

Some further information: if I switch to another request and then switch back, the history does appear as expected. Presumably unmounting and remounting the React component causes it to rerender with the most recent data?