Git Product home page Git Product logo

Comments (65)

woung717 avatar woung717 commented on May 24, 2024 28

I fixed it to make it work. Leetcode changed all the endpoint requires x-csrftoken header.
Thanks for the tips. @kawre

I compiled and uploaded full extension binary. You can download from here.
You can load locally by VSCode -> Extensions Menu -> "..." icon -> Install from VSIX...

You can test from below.
https://github.com/woung717/vscode-leetcode/tree/leetcode-cli-change
https://github.com/woung717/leetcode-cli/tree/fix-cloudflare-issue

But the problem is that leetcode-cli, where I modified, is quite old and no longer seems to be maintained. (Last pull request merge was 2022) Maybe we should fork the branch from leetcode-tools / leetcode-cli and merge into it?

@jdneo Can you check the pull request?

from vscode-leetcode.

dotslash21 avatar dotslash21 commented on May 24, 2024 15

Same issue here :(

I'm using the cookie login but it's not working anymore.

login: (node:27208) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:523:14
    at Request._callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:422:19)
    at self.callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v18.17.1

Update:

Also It seems other folks are facing this issue as well, #478 (comment)

from vscode-leetcode.

berlinway avatar berlinway commented on May 24, 2024 9

find the root cause :) , leetcode website update http proto to allow HTTP/2, letcode-cli request still send http/1.1 request.

from vscode-leetcode.

kawre avatar kawre commented on May 24, 2024 8

Leetcode has updated their cloudflare to block requests without some http headers

For example I've modified vsc-leetcode-cli locally and changing plugin.makeOpts function to include dummy User-Agent and Host headers will make signing in work again

plugin.makeOpts = function(url) {
  const opts = {};
  opts.url = url;
  opts.headers = {};
  opts.headers['Host'] = 'leetcode.com';
  opts.headers['User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0';

  if (session.isLogin())
    plugin.signOpts(opts, session.getUser());
  return opts;
};

In my case, my plugin had to only include new dummy User-Agent header to start working again. kawre/leetcode.nvim#70

This is a bundle of headers that gets sent with every request made by my plugin and everything seems to be working fine

["User-Agent"] = "Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0",
["Referer"] = ("https://leetcode.%s"):format(config.domain),
["Origin"] = ("https://leetcode.%s/"):format(config.domain),
["Content-Type"] = "application/json",
["Accept"] = "application/json",
["Host"] = ("leetcode.%s"):format(config.domain),
["X-Requested-With"] = "XMLHttpRequest",

from vscode-leetcode.

MakiseJ avatar MakiseJ commented on May 24, 2024 8

Guys I reported the issue to Leetcode Support Team last week, and they replied that the problem was fixed today. I think all of us can go on with the extension successfully now.
image
Translation: Thank you for your letter. We have promptly forwarded your feedback to our product and technical teams. The technical team has updated and fixed the issue with the VSCode plugin. We suggest you try again. We will continuously improve such features to provide users with a better learning experience. If you have more suggestions and feedback, please feel free to contact us.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 4

So as @StevenJohnston @jasoncyu said, there are two issues we need to address.

The first is the HTTP header issue, which is about Leetcode changing their Cloudflare - HTTP header policy, and I fixed this in this branch by modifying some headers (thanks to @kawre).

Also, I changed the VSCode prompt login method to the browser method. This is not much related to the issue, but still the prompt ID/PW login method was not working so I fixed it too.

And the second, I suspect, is related to location and cloudflare/HTTP2, as not all users are experiencing the error after the first fix is applied. I can't reproduce the bug, so I can't fix and test it.

To solve this issues completely, I think someone needs to change the HTTP client on one of my branch to support HTTP2. (Or you can fix the HTTP headers on your branch first and then replace HTTP client.)
But the problem is, most of the currently well-maintained CommonJS HTTP2-supporting libraries have different API to the current 'request' API. It may take some time to replace them, and worth noting that bugs are in leetcode-cli.

And again, I hope someone who own this project take care of this issue and see how we can patch it as this is the most popular leetcode extension in VSCode. Otherwise, we have to fork this project and maintain this and leetcode-cli both.

from vscode-leetcode.

gregkonush avatar gregkonush commented on May 24, 2024 3

maintainer has not been active, last commit was 2 years ago

from vscode-leetcode.

berlinway avatar berlinway commented on May 24, 2024 3

find the root cause :) , leetcode website update http proto to allow HTTP/2, letcode-cli request still send http/1.1 request.
if change all request to http/2, it should work well again. Will try to fix that.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 3

I changed the plugin to login using chrome browser.

You can login via id/pw, 3rd party (Github, Linkedin, etc..) at the browser. Select "LeetCode Account" among Sign In options. Cookie option is still available. It might take some time to download chrome browser at first time.

image

You can download plugin(.vsix) file here.

You can load locally by VSCode -> Extensions Menu -> "..." icon -> Install from VSIX...

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024 2

It's cloudflare, i printed out the response that I'm getting on some of the API calls and it says this:

 <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

            <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>

full html here: https://pastebin.com/cTTAf8cb

I got this a few months ago, I wasn't able to figure out a solution, it just ended up going away after a while

from vscode-leetcode.

ChenhaoranY avatar ChenhaoranY commented on May 24, 2024 2

same here, looks like when we try to access /accounts/login, server will give 403, maybe they have upgraded firewall or something. Also not sure why when I try to login with third party I got password incorrect

This is because if you try to use third party login, it will send a verify code to your mailbox. That's why it says password incorrect.

from vscode-leetcode.

kawre avatar kawre commented on May 24, 2024 2

@robpodosek I've only sent an example. Messing around with the headers I've sent I was able to login, open a question and run it.

The problem is that leetcode-cli logs you out if one of the requests return with status code of 403 or 401. To avoid this you would need to ensure that every request sent includes the headers I've mentioned or else you will get logged out if any request fails. But not every request is using plugin.makeOpts to create opts, so this not the only place it needs to be changed.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 2

@robpodosek I forgot to say that it is not published in JetBrain Plugin Marketplace yet. You can download the updated version in the github repository. leetcode-editor-8.10.zip

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024 2

I fixed it to make it work. Leetcode changed all the endpoint requires x-csrftoken header. Thanks for the tips. @kawre

I compiled and uploaded full extension binary. You can download from here. You can load locally by VSCode -> Extensions Menu -> "..." icon -> Install from VSIX...

You can test from below. https://github.com/woung717/vscode-leetcode/tree/leetcode-cli-change https://github.com/woung717/leetcode-cli/tree/fix-cloudflare-issue

But the problem is that leetcode-cli, where I modified, is quite old and no longer seems to be maintained. (Last pull request merge was 2022) Maybe we should fork the branch from leetcode-tools / leetcode-cli and merge into it?

@jdneo Can you check the pull request?

I can confirm this is working for me for both choosing problems and submitting them. Great work! It seems like there was no need to upgrade sending requests to http/2 after all, at least for our cases.

from vscode-leetcode.

MakiseJ avatar MakiseJ commented on May 24, 2024 2

@MakiseJ ID/Password login method was previously blocked. You must login using cookies. Copy from the browser csrftoken=xxx; LEETCODE_SESSION=xxx;

I tried log in with Github and cookies, both of them failed.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at Object.log.<computed> [as info] (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:531:14
    at Request._callback (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:430:19)
    at Request.self.callback (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:527:28)
    at Request.<anonymous> (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:527:28)
login: (node:12296) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

from vscode-leetcode.

hakula139 avatar hakula139 commented on May 24, 2024 2

I changed the plugin to login using chrome browser.

You can login via id/pw, 3rd party (Github, Linkedin, etc..) at the browser. Select "LeetCode Account" among Sign In options. Cookie option is still available. It might take some time to download chrome browser at first time.

image You can download plugin(.vsix) file [here](https://github.com/woung717/vscode-leetcode/releases/tag/Browser_Login_Release).

You can load locally by VSCode -> Extensions Menu -> "..." icon -> Install from VSIX...

It seems I'm still facing the same problem using this extension, tried both browser and cookie.

- Signing in leetcode.com
(node:68028) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
- Retrieving user favorites
[WARN] Favorite not found?
- Retrieving user profile
/Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:65:11
    at /Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/cache.js:92:12
    at /Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:534:14
    at Request._callback (/Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:433:19)
    at self.callback (/Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:513:28)
    at Request.<anonymous> (/Users/hakula/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)

Node.js v18.12.1

Also note that headless browsers may have chances not passing Cloudflare Turnstile (see here), so I used a third-party login method here.

image

And Google also regards this browser as insecure, which may be a hint to the previous problem.

image

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024 2

@woung717 which release should I try now? I noticed some of the earlier ones linked were strikethrough'd. I can give it a shot tonight.

@robpodosek Try Latest release of this link https://github.com/woung717/vscode-leetcode/releases. You can sign in using a Web Browser.

Holy crap this works! I loaded it from the vsix file and everything just loaded. I didn't even have to sign in anywhere (maybe because I was already signed into leetcode). You're a godsend thanks dude.

from vscode-leetcode.

StevenJohnston avatar StevenJohnston commented on May 24, 2024 2

Not my brightest work but heres a fix. https://github.com/StevenJohnston/leetcode-cli

  • "Fixes" cookie login (You select cookie login but provide a cURL copied from your browser)
  • This is a patch for the underlying leetcode-cli package this extension uses. So you will need to tediously install my package in replacement of it. Sorry, I don't feel like forking this extension atm.
  • Does not fix OAuth login. Copied cURL for an OAuth login of course still works.
  • Does not fix leetcode.cn

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024 2

@woung717 I'm using your latest 0.18.1. I've noticed I'm able to load and fetch all the problems, but when I submit a solution I get undefined in the submissions tab. However, when I sign into the problem on leetcode I can see that it actually successfully my solution. So the submission POST is working but it's not properly receiving and/or parsing the response.

Scratch that, it just started working and returning the Accepted submission result in the IDE. I didn't change anything on my end, must have been a leetcode thing.

from vscode-leetcode.

the-m-coder avatar the-m-coder commented on May 24, 2024 2

@woung717
How do we apply your fix? Do we simply over-write the files here?
Screenshot 2024-03-10 at 13 26 54
For reference this directory is in: /Users/current_user/.vscode/extensions/leetcode.vscode-leetcode-0.18.1

@codevisualisations See this. https://superuser.com/questions/73675/how-do-i-install-a-vsix-file-in-visual-studio

@woung717 can confirm the changes let me login and submit. thanks for your work.

Anyone else who wants to install woung's patch just follow this guide https://www.youtube.com/watch?v=Z724l3mq2ag after downloading his latest release as a .vsix file: https://github.com/woung717/vscode-leetcode/releases

from vscode-leetcode.

tamy-le avatar tamy-le commented on May 24, 2024 2

I'm following this and it worked, detail steps :(:
#skygragon/leetcode-cli#194 (comment)

  1. Right mouse click on leetcode page (please sign in first so it can give you session cookie) -> inpsect -> network -> reload -> any graphQL:
    Screenshot 2024-04-02 at 01 02 06
  2. Copy correct value corresponding to correct field to json file ~/.lc/leetcode/user.json (may create by self)
    Content in user.json should be like this:
{
  "login": "[username]",
  "loginCSRF": "",
  "sessionCSRF": "[copied from csrftoken]",
  "sessionId": "[copied from LEETCODE_SESSION]"
}

then just open vscode and use extension normally - may need 1~2 seconds to sign in

from vscode-leetcode.

sff2578 avatar sff2578 commented on May 24, 2024 1

It's cloudflare, i printed out the response that I'm getting on some of the API calls and it says this:

 <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

            <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>

full html here: https://pastebin.com/cTTAf8cb

I got this a few months ago, I wasn't able to figure out a solution, it just ended up going away after a while

How long did it take to work again?

from vscode-leetcode.

ChenhaoranY avatar ChenhaoranY commented on May 24, 2024 1

Same issue here :(

I'm using the cookie login but it's not working anymore.

login: (node:27208) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:523:14
    at Request._callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:422:19)
    at self.callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v18.17.1

Update:

Also It seems other folks are facing this issue as well, #478 (comment)

Have you solved this problem

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024 1

find the root cause :) , leetcode website update http proto to allow HTTP/2, letcode-cli request still send http/1.1 request.

hmm I tried replacing the library with some ones that send http/2 requests, I'm still getting the same cloudflare 403 error page in response. Hopefully you get some better luck than me

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024 1

I added those lines to /Users/myuser/.nvm/versions/node/v18.18.2/lib/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js but it doesn't seem to have any effect when I use the cookie login.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 1

For those who urgently need a leetcode IDE solution, this is an alternative. https://plugins.jetbrains.com/plugin/12132-leetcode-editor https://github.com/shuzijun/leetcode-editor/releases You can use the plugin with the free JetBrain IDEs. The plugin bypasses the CloudFlare problem with the in-IDE browser. By the way, I hope the issue is solved.

Edit: Changed a link. (Plugin MarketPlace -> Github Repository)

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 1

I think I can fix the ID/Password method too if it is okay to add selenium or puppeteer... Since browser dependency might cause compatibility issue, though.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 1

@hakula139 As you see the web page, it is not a headless browser. It's a just standalone Chrome browser but just controlled by automated program. (leetcode-cli in this case) And about the Turnstile fail, it display failure, however you can login if you click the "Sign In" button. I saw there are some kind of puppeteer plugin to make it stealth mode, but I couldn't test since it works without the plugin. Anyway, thank you for your report. I'll see it more.

For someone who have enough time, I think we need investigate can HTTP2 fix failures which some users have. Leet-cli still use 'request' http client to query after browser login proccess.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 1

Login issue is fixed by @woung717 's release, but got another issue:

Fetch solution failed.

image

@ryderfang Thank you for the report. Which Release/Endpoint(leetcode.com or leetcode.cn) do you use?

Add: I forgot to update Fixed_Release's dependencies. I updated and uploaded binary again. Check this if you have used Fixed_Release and leetcode.com endpoint.

from vscode-leetcode.

ryderfang avatar ryderfang commented on May 24, 2024 1

@woung717 I used "leetcode.com", your latest release worked perfect! Great job, Thanks!

from vscode-leetcode.

wallacezzzzz007 avatar wallacezzzzz007 commented on May 24, 2024 1

@woung717 I tried your newest release, it works perfectly! thank you!

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024 1

Not my brightest work but heres a fix. https://github.com/StevenJohnston/leetcode-cli

  • "Fixes" cookie login (You select cookie login but provide a cURL copied from your browser)
  • This is a patch for the underlying leetcode-cli package this extension uses. So you will need to tediously install my package in replacement of it. Sorry, I don't feel like forking this extension atm.
  • Does not fix OAuth login. Copied cURL for an OAuth login of course still works.
  • Does not fix leetcode.cn

very nice! Less changes needed than I thought. can confirm it works for me

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024 1

@woung717 Okay so the 0.18.1 patch wasn't working (see my strikethrough'd comment above). Then it was working last night. Now it's back to not working, it's posting the code to leetcode when I check on the site, but in vscode it's showing 'undefined' again and saying that my session is expired despite still posting the code to leetcode. I'm also still getting the padLevels error.

- Sending code to judge
(node:43334) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
- Waiting for judge result
[ERROR] session expired, please login again [code=-1]

edit: aaaand now it's working again and returning the result in VS Code. This seems to be an intermittent issue on the leetcode side.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024 1

@robpodosek From my experience, if you access leetcode on the browsers and do something on this extension at the same time, session can be expired. So I submit and see code only on the extension.

edit: I faced the same situation without any additional web browser session, and it occurred when I submitted code multiple times too quickly. I think it is a leetcode side problem. Maybe retry logic can be added but it would be not easy.

from vscode-leetcode.

lemonsher avatar lemonsher commented on May 24, 2024

Same issue here :(

I'm using the cookie login but it's not working anymore.

login: (node:27208) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:523:14
    at Request._callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:422:19)
    at self.callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v18.17.1

Update:

Also It seems other folks are facing this issue as well, #478 (comment)

Same

from vscode-leetcode.

wangyerdfz avatar wangyerdfz commented on May 24, 2024

Same issue here :(

I'm using the cookie login but it's not working anymore.

login: (node:27208) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:523:14
    at Request._callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:422:19)
    at self.callback (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:514:28)
    at Request.<anonymous> (c:\Users\XXXXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:514:28)

Node.js v18.17.1

Update:

Also It seems other folks are facing this issue as well, #478 (comment)

Node.js v20.11.0
login: (node:1480417) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
/home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at /home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (/home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/log.js:55:20)
    at /home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/commands/user.js:121:13
    at /home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:523:14
    at Request._callback (/home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/vsc-leetcode-cli/lib/plugins/leetcode.js:422:19)
    at self.callback (/home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:185:22)
    at Request.emit (node:events:518:28)
    at Request.<anonymous> (/home/**user**/.vscode/extensions/leetcode.vscode-leetcode-0.18.1/node_modules/request/request.js:1161:10)
    at Request.emit (node:events:518:28)

Node.js v20.11.0
- Waiting session result
(node:1505451) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
[ERROR] session expired, please login again [code=-1]

Same.

Ubuntu 20.04
Node v20.11.0
Vs Code 1.87.0
Extension version: 0.18.1

update 1: uploaded log

from vscode-leetcode.

sff2578 avatar sff2578 commented on May 24, 2024

same here, looks like when we try to access /accounts/login, server will give 403, maybe they have upgraded firewall or something. Also not sure why when I try to login with third party I got password incorrect

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024

It's cloudflare, i printed out the response that I'm getting on some of the API calls and it says this:

 <p data-translate="blocked_why_detail">This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.</p>
          </div>

          <div class="cf-column">
            <h2 data-translate="blocked_resolve_headline">What can I do to resolve this?</h2>

            <p data-translate="blocked_resolve_detail">You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.</p>

full html here: https://pastebin.com/cTTAf8cb
I got this a few months ago, I wasn't able to figure out a solution, it just ended up going away after a while

How long did it take to work again?

I'm not sure, maybe a couple of days. I tried github sign in, linkedin signin, cookie signin, and all failed. I also tried this alternative: https://github.com/clearloop/leetcode-cli and I also had the exact same issue. Somehow Cloudflare is not letting me through. I also tried behind a VPN and also by manipulating my request headers so they are more similar to my browser's also no good.

from vscode-leetcode.

fanzhangvivian avatar fanzhangvivian commented on May 24, 2024
TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at log.<computed> [as info] (c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:523:14
    at Request._callback (c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:422:19)
    at self.callback (c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:519:28)
    at Request.<anonymous> (c:\Users\Fan Zhang\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:519:28)

Node.js v21.7.0``

I also met the problem. is there anybody solve it? I can't sign in leetcode in vscode for ten days.

from vscode-leetcode.

berlinway avatar berlinway commented on May 24, 2024

same issue in Singapore, seems some day before, leetcode has been attacked and open some toggle.

from vscode-leetcode.

garvit3835 avatar garvit3835 commented on May 24, 2024

Same issue. Can it be resolved by any way?

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

Please berlinway, you're our only hope. This is so disheartening, I love this extension. At least I'm not crazy and not the only one with this issue.

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

Even if we get a fix what do we do if the maintainer isn't around to accept a new pull request and create a new 18.2 release? Last release was almost 2 years ago. Will we have to patch locally?

from vscode-leetcode.

StevenJohnston avatar StevenJohnston commented on May 24, 2024

I managed to get cookie login working with fetch-h2. But the cookies on their own are not enough. I had to copy my headers over from my browser request as well. Probably worth noting that this issue is ultimately with the leetcode-cli package. Which if you have been logging in via cookies, we have been using a fork this whole time anyway (this one https://github.com/leetcode-tools/leetcode-cli) also might be dead.. ๐Ÿ˜‚

Ill likely create a fork of leetcode-tools/leetcode-cli and try to get it merged. If not, it could just replace it.

Im not sure if hard-coding the headers will be a long term solution (I have yet to test which are needed) but another solution might be to paste in the a curl request rather than the cookies alone. I've done 0 testing with the OAuth as i didn't trust passing my creds into a vscode prompt lol.

Ill stay posted.

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024

I managed to get cookie login working with fetch-h2. But the cookies on their own are not enough. I had to copy my headers over from my browser request as well. Probably worth noting that this issue is ultimately with the leetcode-cli package. Which if you have been logging in via cookies, we have been using a fork this whole time anyway (this one https://github.com/leetcode-tools/leetcode-cli) also might be dead.. ๐Ÿ˜‚

Ill likely create a fork of leetcode-tools/leetcode-cli and try to get it merged. If not, it could just replace it.

Im not sure if hard-coding the headers will be a long term solution (I have yet to test which are needed) but another solution might be to paste in the a curl request rather than the cookies alone. I've done 0 testing with the OAuth as i didn't trust passing my creds into a vscode prompt lol.

Ill stay posted.

ah interesting, I tried something similar with http2 and also copying my own headers, but I still hit a cloudflare page. It's heartening that someone got it working at least.

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

Thanks for your diligent work. Please keep up posted and post any instructions/work-arounds (eg direct curl) once you find them. Thanks again.

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

@woung717 I seem to be having issues with that plugin as well, even if I do the cookie login. Maybe I'm doing something wrong...

from vscode-leetcode.

MakiseJ avatar MakiseJ commented on May 24, 2024

I fixed it to make it work. Leetcode changed all the endpoint requires x-csrftoken header. Thanks for the tips. @kawre

I compiled and uploaded full extension binary. You can download from here. You can load locally by VSCode -> Extensions Menu -> "..." icon -> Install from VSIX...

You can test from below. https://github.com/woung717/vscode-leetcode/tree/leetcode-cli-change https://github.com/woung717/leetcode-cli/tree/fix-cloudflare-issue

But the problem is that leetcode-cli, where I modified, is quite old and no longer seems to be maintained. (Last pull request merge was 2022) Maybe we should fork the branch from leetcode-tools / leetcode-cli and merge into it?

@jdneo Can you check the pull request?

Thanks for your work, but I tried your extension, it's still blocked

 Active  Name               Version         Desc
----------------------------------------------------------------------------------------------------
   โˆš     solution.discuss   2019.02.03      Plugin to fetch most voted solution in discussions.
   โˆš     company            2017.12.18      Plugin to query by company for free user.
   โˆš     cache              default         Plugin to provide local cache.
   โˆš     retry              default         Plugin to retry last failed request if autologin.enable is on.
   ร—     leetcode.cn        2018.11.25      Plugin to talk with leetcode-cn APIs.
   โˆš     leetcode           default         Plugin to talk with leetcode APIs.
(node:20780) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
 Premium   User                 Host
------------------------------------------------------------
    ร—      undefined            https://leetcode.com
(node:20924) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
- Downloading problems
(node:21040) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
[ERROR] session expired, please login again [code=-1]
login: (node:17832) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
pass: [ERROR] Login failed. Please make sure the credential is correct.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024

@MakiseJ ID/Password login method was previously blocked. You must login using cookies. Copy from the browser csrftoken=xxx; LEETCODE_SESSION=xxx;

from vscode-leetcode.

StevenJohnston avatar StevenJohnston commented on May 24, 2024

Unless some people are hitting a different Cloudflare server, HTTP/1.1 is still a problem. I have curl request that will 403 if I use HTTP/1.1 but work with HTTP/2.

from vscode-leetcode.

jasoncyu avatar jasoncyu commented on May 24, 2024

Unless some people are hitting a different Cloudflare server, HTTP/1.1 is still a problem. I have curl request that will 403 if I use HTTP/1.1 but work with HTTP/2.

Yeah, I think there could be two different issues. Does anyone have a source about leetcode upgrading to require http/2? I seem to be getting through still using http/1.1

from vscode-leetcode.

the-m-coder avatar the-m-coder commented on May 24, 2024

@woung717

How do we apply your fix? Do we simply over-write the files here?

Screenshot 2024-03-10 at 13 26 54

For reference this directory is in:
/Users/current_user/.vscode/extensions/leetcode.vscode-leetcode-0.18.1

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

Has anyone got any workarounds to work in the meantime?

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024

@woung717

How do we apply your fix? Do we simply over-write the files here?

Screenshot 2024-03-10 at 13 26 54 For reference this directory is in: `/Users/current_user/.vscode/extensions/leetcode.vscode-leetcode-0.18.1`

@codevisualisations
See this. https://superuser.com/questions/73675/how-do-i-install-a-vsix-file-in-visual-studio

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024

@robpodosek Do you still have the same issue with this?

@MakiseJ ID/Password login method was previously blocked. You must login using cookies. Copy from the browser csrftoken=xxx; LEETCODE_SESSION=xxx;

I tried log in with Github and cookies, both of them failed.

cookie: - Retrieving user favorites
[WARN] Failed to retrieve user favorites: [object Object]
- Retrieving user profile
c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55
      let s = args.map(x => x.toString()).join(' ');
                              ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:31
    at Array.map (<anonymous>)
    at Object.log.<computed> [as info] (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\log.js:55:20)
    at c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\commands\user.js:121:13
    at c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:531:14
    at Request._callback (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\vsc-leetcode-cli\lib\plugins\leetcode.js:430:19)
    at Request.self.callback (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:185:22)
    at Request.emit (node:events:527:28)
    at Request.<anonymous> (c:\Users\XXX\.vscode\extensions\leetcode.vscode-leetcode-0.18.1\node_modules\request\request.js:1161:10)
    at Request.emit (node:events:527:28)
login: (node:12296) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

@woung717 which release should I try now? I noticed some of the earlier ones linked were strikethrough'd. I can give it a shot tonight.

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024

@woung717 which release should I try now? I noticed some of the earlier ones linked were strikethrough'd. I can give it a shot tonight.

@robpodosek Try Latest release of this link https://github.com/woung717/vscode-leetcode/releases. You can sign in using a Web Browser.

from vscode-leetcode.

yuangu002 avatar yuangu002 commented on May 24, 2024

@woung717 No matter which version of release I applied or which method to login (web browser or using cookies), it was giving the same reading toString() from undefined error.

from vscode-leetcode.

berlinway avatar berlinway commented on May 24, 2024

@hakula139 As you see the web page, it is not a headless browser. It's a just standalone Chrome browser but just controlled by automated program. (leetcode-cli in this case) And about the Turnstile fail, it display failure, however you can login if you click the "Sign In" button. I saw there are some kind of puppeteer plugin to make it stealth mode, but I couldn't test since it works without the plugin. Anyway, thank you for your report. I'll see it more.

For someone who have enough time, I think we need investigate can HTTP2 fix failures which some users have. Leet-cli still use 'request' http client to query after browser login proccess.

try to fix with http2, but failed. I am not familiar with js.
there have a solution, we should use http2 stream operation

If someone familiar with js can help fix with http2 stream half fix branch

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024

I fixed HTTP headers related to csrftoken at the first release, and in second release, I changed sign-in process to browser method. But both releases still use 'rquest' library(only support HTTP 1.1) to get and submit leetcode data after sign-in. But it's weird since I don't have that issue in Korea. I think it might related with user's location and Cloudflare. Does Cloudflare force HTTP2 connection?

from vscode-leetcode.

berlinway avatar berlinway commented on May 24, 2024

That's weird since I don't have that issue in Korea. I think it might related with user's location and CloudFlare. Does Cloudflare force HTTP2 connection?

it's easy to answer ur question, u can capture package from leetcode.com website, u will find most of request change to http2.
Not cloudflare force http2, it's leetcode upgrade their protocol to http2.

ur solution maybe work temporary. finally ur solution won't work anymore, the root cause is http2

from vscode-leetcode.

woung717 avatar woung717 commented on May 24, 2024

That's weird since I don't have that issue in Korea. I think it might related with user's location and CloudFlare. Does Cloudflare force HTTP2 connection?

it's easy to answer ur question, u can capture package from leetcode.com website, u will find most of request change to http2. Not cloudflare force http2, it's leetcode upgrade their protocol to http2.

ur solution maybe work temporary. finally ur solution won't work anymore, the root cause is http2

That's the point I can't understand, I saw Leetcode website upgrade protocol to HTTP2 at the browser but still I can communicate using 'request' library (HTTP 1.1) in here. If website's HTTP2 requirement is the real problem, then I should have same error, but I don't. That's way I guess Cloudflare force it depends on the user's location.

from vscode-leetcode.

ryderfang avatar ryderfang commented on May 24, 2024

Login issue is fixed by @woung717 's release, but got another issue:

Fetch solution failed.

image

from vscode-leetcode.

alexya avatar alexya commented on May 24, 2024

I met a similar issue

let s = args.map(x => x.toString()).join(' ');
                              ^
TypeError: Cannot read properties of undefined (reading 'toString')

from vscode-leetcode.

robpodosek avatar robpodosek commented on May 24, 2024

@woung717 agreed. Being logged into leetcode in the browser at the same time doesn't seem to have any effect on the extension. It was working for me this morning, then I went onto the next problem and now I'm back to 'undefined'. I bet if I try again in a few hours it'll suddenly magically work. Seems like a roll of the dice.

The cookie is working though because I can see my submission posted to leetcode although I'm getting an undefined response.

edit: yeah it started working again after a few hours

from vscode-leetcode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.