From f109ffa9bc1d09fc0c2cdb56010d922dd508ce95 Mon Sep 17 00:00:00 2001 From: chain710 Date: Wed, 8 Feb 2023 20:33:11 +0800 Subject: [PATCH 1/2] cookieJar.setCookieSync ignore error cookieJar.setCookieSync crash node when error, like: ``` uncaughtException: Error: Cookie not in this host's domain. Cookie:example.com Request:127.0.0.1 ``` --- src/utils/proxy/cookie-jar.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/proxy/cookie-jar.js b/src/utils/proxy/cookie-jar.js index b88bc6008..6acbbfadb 100644 --- a/src/utils/proxy/cookie-jar.js +++ b/src/utils/proxy/cookie-jar.js @@ -33,7 +33,8 @@ export function addCookieToJar(url, headers) { cookies = [cookie]; } + const options = { ignoreError: true }; for (let i = 0; i < cookies.length; i += 1) { - cookieJar.setCookieSync(cookies[i], url.toString()); + cookieJar.setCookieSync(cookies[i], url.toString(), options); } } From 3600e5487deb621b791f0bdb08cf9450078d2995 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 8 Feb 2023 08:30:53 -0800 Subject: [PATCH 2/2] Apply suggestions from #964 code review --- src/utils/proxy/cookie-jar.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils/proxy/cookie-jar.js b/src/utils/proxy/cookie-jar.js index 6acbbfadb..6519231cc 100644 --- a/src/utils/proxy/cookie-jar.js +++ b/src/utils/proxy/cookie-jar.js @@ -33,8 +33,7 @@ export function addCookieToJar(url, headers) { cookies = [cookie]; } - const options = { ignoreError: true }; for (let i = 0; i < cookies.length; i += 1) { - cookieJar.setCookieSync(cookies[i], url.toString(), options); + cookieJar.setCookieSync(cookies[i], url.toString(), { ignoreError: true }); } }