question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CURL code generation not working

See original GitHub issue

Describe the bug “Generate Code” and “Copy as CURL” functionality not working

To Reproduce Steps to reproduce the behavior:

  1. Create request
  2. Click on “Generate Code” or “Copy as CURL”

Expected behavior Generated CURL code or CURL request in clipboard

Screenshots An error in developer tools console:

/opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/cookie.js:941 Uncaught (in promise) TypeError: Cannot read property 'getTime' of null
    at Cookie.expiryTime (/opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/cookie.js:941)
    at matchingCookie (/opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/cookie.js:1175)
    at Array.filter (<anonymous>)
    at /opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/cookie.js:1188
    at MemoryCookieStore.findCookies (/opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/memstore.js:113)
    at CookieJar.getCookies (/opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/cookie.js:1183)
    at CookieJar.getCookiesSync (/opt/Insomnia/resources/app.asar/node_modules/tough-cookie/lib/cookie.js:1452)
    at getRequestCookies (bundle.js:74505)
    at exportHarWithRenderedRequest (bundle.js:74493)
    at process._tickCallback (internal/process/next_tick.js:68)

Desktop (please complete the following information):

  • OS: Linux Mint 19.3 Tricia
  • Installation Method: deb package
  • App Version 2020.3.3 (though didn’t work on 2020.2.2 either)

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jgiovarescocommented, Oct 22, 2020

I’ve started to work on this, but there is something weird in the cookies modal logic.

I’ve taken a record when I’ve created a cookie and played with the Expires attribute 2482-cookies-modal

As you can see, there is something wrong. I’ve found the cause in those lines: https://github.com/Kong/insomnia/blob/c73092e2947d3eaf059473086b178fa2fe117df0/packages/insomnia-app/app/ui/components/modals/cookie-modify-modal.js#L112-L117

When we are saving changes, the value in cookie.expires is "0" instead of 0. Therefore we are “generating” a date using new Date('0') which different than new Date(0) 🤯

We should fix that, but I’d like your thoughts on what format we want to use in the Expires input? I’m thinking about:

  1. using a number (epoch time): 1603396449844
  2. using the UTC string (which is the format described in the RFC if I read it correctly ): Thu, 22 Oct 2020 19:54:09 GMT
  3. using the ISO string: 2020-10-22T19:54:09.844Z

I would use the 3rd option, the ISO string, which seems to be the simpler. Indeed, I can’t convert the epoch time in my head, and we would need to update the day matching the new date using the UTC. 🤔

Of course, this format would be used only in the input field. We would then adapt it when we update the cookie.

1reaction
jgiovarescocommented, Oct 20, 2020

@jrodalo Thanks! I can reproduce 🎉 🙇

Read more comments on GitHub >

github_iconTop Results From Across the Web

curl, API request works in Insomnia, but not in generated code ...
When I send it via Insomnia, no problemo. But when I generate source code for curl, it shows me this. curl --request POST...
Read more >
curl_error - Manual - PHP
Returns a clear text error message for the last cURL operation. ... close the current cURL session or the error message will be...
Read more >
build and install curl from source
This document does not describe how to install curl or libcurl using such a binary package. This document describes how to compile, build...
Read more >
Exit status - Everything curl
If you write a shell script or batch file that invokes curl, you can always check the return code to detect problems in...
Read more >
Generate Code for cURL not work - Help - Postman community
hi, I try to use a code generate for cURL (windows), but not work, please see … Have any idea ?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found