Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot delete property 'creationIndex' of [object Object] #199

Open
Lekinio opened this issue Jul 15, 2020 · 7 comments
Open

Cannot delete property 'creationIndex' of [object Object] #199

Lekinio opened this issue Jul 15, 2020 · 7 comments
Assignees
Projects

Comments

@Lekinio
Copy link

Lekinio commented Jul 15, 2020

hello when i am trying to set new cookie it return this error:

Cannot delete property 'creationIndex' of [object Object]

cookie:

new Cookie({
     key: '',
     value: '',
     expires: 
     maxAge: ,
     domain: '',
     path: '/',
     secure: ,
     hostOnly: ,
     creation: 
     lastAccessed:
   });

cookieJar.setCookie(cookie, 'url');

@ruoho ruoho self-assigned this Aug 24, 2020
@ruoho
Copy link
Contributor

ruoho commented Sep 21, 2020

Hi @Lekinio, could you provide the full code here so that we can reproduce? Thanks!

@awaterma
Copy link
Member

No feedback provided, closing this issue out. Please feel free to reopen if you can pass on the code to reproduce the issue (preferably as a vows based unit test).

@rumen-makeen
Copy link

Hi. I'm having the exact same issue at the moment. Here are some basics for reproduction:

  1. Using the request library (latest version), after running several requests, I have the following jar:
RequestJar {
  _jar: CookieJar {
    enableLooseMode: true,
    store: { idx: {
      'identity.trinet.com': {
        '/': {
          JSESSIONID: Cookie="JSESSIONID=AE736F56E732EF38FD3D1A4345542A20; Path=/; Secure; HttpOnly; hostOnly=true; aAge=2275ms; cAge=19631ms",
          t: Cookie="t=default; Path=/; hostOnly=true; aAge=2276ms; cAge=19632ms",
          DT: Cookie="DT=DI0UlaG6NTNTriz6HgZ_VGSFw; Expires=Thu, 09 Feb 2023 19:06:21 GMT; Path=/; Secure; hostOnly=true; aAge=3115ms; cAge=19631ms",
          sid: Cookie="sid=1024m3o1cPxSMq94AEOsoNNvQ; Path=/; Secure; hostOnly=true; aAge=2275ms; cAge=3127ms"
        }
      },
      'hrpassport.com': {
        '/': {
          __cfduid: Cookie="__cfduid=dab3b1e3bf5c434fad0e6b263f2442b471612897599; Expires=Thu, 11 Mar 2021 19:06:39 GMT; Domain=hrpassport.com; Path=/; HttpOnly; SameSite=Lax; hostOnly=false; aAge=555ms; cAge=961ms",
          TriNetAuthCookie: Cookie="TriNetAuthCookie=b53246b59bc42fc490ffac7a6eb94a03bcec0ac9ba8f080e9c81bcfe492102b1; Domain=hrpassport.com; Path=/; SameSite=Lax; hostOnly=false; aAge=555ms; cAge=955ms"
        }
      },
      'trinet.hrpassport.com': {
        '/': {
          ADRUM_BT: Cookie="ADRUM_BT=R:0|g:df24a0e5-572f-48f6-8244-71a1c0ce0ad2290290|n:trinet-prod_1baf75e7-1242-48ad-9578-5276bbaf10cb|i:1151882|d:143|e:40; Expires=Tue, 09 Feb 2021 19:07:11 GMT; Path=/; hostOnly=true; aAge=4ms; cAge=950ms"
        }
      }
    } }
  }
}
  1. I run a request using that jar & the request module uses tough-cookie to process the jar.
  2. While processing the jar, I get the Cannot delete property 'creationIndex' of [object Object] error, at line 1283 of node_modules/request/node_modules/tough-cookie/lib/cookie.js.

I logged the cookie array that cookies.map is performed on (the error is within the said cookies.map loop) and I get this:

[
  Cookie="JSESSIONID=AE736F56E732EF38FD3D1A4345542A20; Path=/; Secure; HttpOnly; hostOnly=true; aAge=2698ms; cAge=20054ms",
  Cookie="t=default; Path=/; hostOnly=true; aAge=2698ms; cAge=20054ms",
  Cookie="DT=DI0UlaG6NTNTriz6HgZ_VGSFw; Expires=Thu, 09 Feb 2023 19:06:21 GMT; Path=/; Secure; hostOnly=true; aAge=3537ms; cAge=20053ms",
  Cookie="sid=1024m3o1cPxSMq94AEOsoNNvQ; Path=/; Secure; hostOnly=true; aAge=2697ms; cAge=3549ms",
  Cookie="__cfduid=dab3b1e3bf5c434fad0e6b263f2442b471612897599; Expires=Thu, 11 Mar 2021 19:06:39 GMT; Domain=hrpassport.com; Path=/; HttpOnly; SameSite=Lax; hostOnly=false; aAge=419ms; cAge=1383ms",
  Cookie="TriNetAuthCookie=b53246b59bc42fc490ffac7a6eb94a03bcec0ac9ba8f080e9c81bcfe492102b1; Domain=hrpassport.com; Path=/; SameSite=Lax; hostOnly=false; aAge=419ms; cAge=1377ms",
  Cookie="ADRUM_BT=R:0|g:649309a6-67e9-4d3f-992f-4c1646c8ce4c266377|n:trinet-prod_1baf75e7-1242-48ad-9578-5276bbaf10cb|i:1151882|d:7|h:e|e:52; Expires=Tue, 09 Feb 2021 19:07:11 GMT; Path=/; hostOnly=true; aAge=9ms; cAge=1372ms"
]

I also logged the cookie inside the loop (console.log(typeof cookie, cookie)), right before the line that produces the error, and I get this:
object Cookie="JSESSIONID=AE736F56E732EF38FD3D1A4345542A20; Path=/; Secure; HttpOnly; hostOnly=true; aAge=2699ms; cAge=20055ms"

npm ls | grep tough-cookie gives me v4.0.0 (latest at the time of writing this).
Any help will be MUCH appreciated.

@awaterma
Copy link
Member

awaterma commented Feb 9, 2021

I'll reopen this and we'll take a look. If you'd like to convert this into a Vows based unit test, that would be very appreciated. :)

@awaterma awaterma reopened this Feb 9, 2021
@thehamsti
Copy link

I am also having this issue was there any resolution?

@ruoho-sfdc ruoho-sfdc assigned awaterma and unassigned ruoho Jul 19, 2021
@awaterma awaterma added this to To do in 4.2 Release via automation Mar 21, 2022
@justinddunlap
Copy link

justinddunlap commented Feb 10, 2023

This happens when you put cookies in your CookieJar that are instances of a Cookie class defined in another version of tough-cookie. This is quite easy to do when you're using a lib like the one for FileCookieStore. It results in cookie instanceof Cookie being false while cookie.constructor.name == "Cookie".

To fix this, dedupe the library with overrides in your package.json or use some tool to force the same version of tough-cookie everywhere.

I argue that the maintainers of this library should not use instanceof in this context though.

@wjhsf
Copy link
Contributor

wjhsf commented Feb 13, 2023

Thanks for that insight, @justinddunlap. It would be nice if users didn't have to worry about version mismatches. However, if we allowed a CookieJar to accept different versions of Cookie, we would likely be introducing a path for much subtler bugs to occur. By using instanceof, we are guaranteeing that the CookieJar knows exactly what kind of Cookie it is receiving, so we have a smaller surface area to test. We may be able to do a duck typing check, rather than use instanceof, but the work required to implement that (and properly test to avoid regressions) is more than we currently have capacity for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

No branches or pull requests

7 participants