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.

v2.5.0 : str.trim() is not a function

See original GitHub issue

We’re using tough-cookie ^2.4.3 (which actually installs 2.5.0) with request ^2.88.0.

This code worked with 2.4.3 :

const cookiesJar = requestModule.jar();
 _.forEach(initialCookies, (cookie: Object) => {
 const newCookie = toughCookie.fromJSON(JSON.stringify(cookie));
 const hostUrl = `${initialOptions.protocol}//${initialOptions.host}/`;
 cookiesJar.setCookie(newCookie, hostUrl);
});

But we’re getting the following error with 2.5.0 :

TypeError: str.trim is not a function
 at Function.parse (node_modules/request/node_modules/tough-cookie/lib/cookie.js:429:13)
 at CookieJar.setCookie (node_modules/request/node_modules/tough-cookie/lib/cookie.js:1011:21)
 at CookieJar.setCookieSync (node_modules/request/node_modules/tough-cookie/lib/cookie.js:1402:18)
 at RequestJar.setCookie (node_modules/request/lib/cookies.js:25:20)

Any hint about what could cause this issue in 2.5.0?

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:15
  • Comments:24 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
KevinGong2013commented, Aug 30, 2019
Screen Shot 2019-08-30 at 4 25 08 PM

typescript (cookie instanceof Cookie) return false.

@awaterma

workaround

jar.setCookie(JSON.stringify(cookie), '.teamaster.club')
5reactions
legowerewolfcommented, Jun 24, 2019

I’m still seeing this with v3.0.1.

$ npm ls --depth=0
+-- @types/commander@2.12.2
+-- @types/inquirer@6.0.3
+-- @types/node@12.0.10
+-- @types/request-promise-native@1.0.16
+-- @types/tough-cookie@2.3.5
+-- commander@2.20.0
+-- idx@2.5.6
+-- inquirer@6.4.1
+-- request@2.88.0
+-- request-promise-native@1.0.7
+-- tough-cookie@3.0.1
`-- typescript@3.5.2
Read more comments on GitHub >

github_iconTop Results From Across the Web

[Solved] TypeError: trim is not a function - ItsJavaScript
The TypeError: trim is not a function occurs if we call a trim() method on the value that is not of a type...
Read more >
TypeError: trim is not a function in JavaScript | bobbyhadz
The "trim is not a function" error occurs when we call the trim() method on a value that is not a string. To...
Read more >
javascript - .trim() is not a function - Stack Overflow
Even if you start with a string instead of an array then the split method returns an array and there is no trim...
Read more >
String.prototype.trim() - JavaScript - MDN Web Docs
The trim() method removes whitespace from both ends of a string and returns a new string, without modifying the original string.
Read more >
String.Trim Method (System) - Microsoft Learn
Returns a new string in which all leading and trailing occurrences of a set of specified characters from the current string are removed....
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