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.86k stars 1.97k forks source link

Adding a script causes unexpected request failure #7976

Closed ftiercelin closed 3 weeks ago

ftiercelin commented 1 month ago

Expected Behavior

In scratchpad mode, I created a request that does a GET on https://www.google.com I ran the request successfully. I then added an after-response script that does: console.log("hello!");

Actual Behavior

after adding the script, the request consistently fails with error: Execute after-response script failed: TypeError: Cannot convert undefined or null to object insomnia_script_error_msg

Reproduction Steps

in scratchpad mode:

  1. create a new HTTP request doing a GET to https://www.google.com
  2. add a script (e.g. console.log("hello"); )
  3. execute script insomnia_script_error

Is there an existing issue for this?

Additional Information

Version: Insomnia 10.0.0 Build date: 9/9/2024 OS: Windows_NT x64 10.0.19045 Electron: 31.4.0 Node: 20.16.0 Node ABI: 125 V8: 12.6.228.30-electron.0 Architecture: x64

Insomnia Version

10.0.0

What operating system are you using?

Windows

Operating System Version

Windows_NT x64 10.0.19045

Installation method

insomnia automated update

Last Known Working Insomnia version

n/a

subnetmarco commented 1 month ago

@ihexxa

ftiercelin commented 1 month ago

forgot to mention that I'm only seeing this in scratchpad mode - not seeing this in "normal" mode

ihexxa commented 1 month ago

This is weird, I can't reproduce, probably I missed something. Is there any folder-level script? Could you check this:

  1. Go to "help" menu, click "show/hide hidden window"
  2. Click the hidden window, go to top menu "view" -> "toggle devTools"
  3. Send the problematic request
  4. see is there any error in the devTool -> Console Tab (see screenshot 2)

Thank you for the detailed report.

Screenshot 2024-09-20 at 15 26 35 image
ftiercelin commented 1 month ago

Thanks @ihexxa for looking into this, I tried the help menu but could not locate the show/hide option you were referring to: insomnia_help_menu_scratchpad

I ran again the query (which failed for the same reason), here are the console logs: insomnia_console_scratchpad.txt

I looked in the folder, no script:

insomnia_folder_scratchpad

might be worth mentioning that:

  1. I used google here as an example, the behaviour applies to any url I tried
  2. we're behind a Zscaler proxy (don't think that could play a role, but...)
ihexxa commented 1 month ago

I tried to enable the proxy in the scratchpad mode still not able to reproduce it. I may improve the error message to help identify it in the next.

ftiercelin commented 1 month ago

Thanks @ihexxa, I'll retry when the next version is pushed out.

ihexxa commented 3 weeks ago

Hello @ftiercelin , would you mind to update to 10.1, which provides more information and could be helpful for us to identify the issue.

ftiercelin commented 3 weeks ago

Hi @ihexxa , I upgraded to 10.0.1, logout, started scratchpad mode. I can't provide you logs of the failure, because, well.... it's not failing anymore 👍 I have added a pre script (in addition to the existing after script), still works fine.

ftiercelin commented 3 weeks ago

no longer failing after upgrading to 10.0.1

FunkySamuel37 commented 1 week ago
image

I ran into a similar issue. When there's content in the pre-script, the HTTP proxy turns into NaN.

ihexxa commented 1 week ago

Thanks @FunkySamuel37, it's revealing, let me check.