iamhyc / Overleaf-Workshop

Open Overleaf/ShareLaTex projects in vscode, with full collaboration support.
https://marketplace.visualstudio.com/items?itemName=iamhyc.overleaf-workshop
GNU Affero General Public License v3.0
476 stars 10 forks source link

Versions 0.5.2 and below can access self-hosted sharelatex projects normally, but versions 0.5.3 and above cannot. #74

Closed fbotp closed 8 months ago

fbotp commented 8 months ago

Describe the bug

When installing versions 0.5.3 and above, you can log in to self-hosted sharelatex normally through passwords and cookies, but you cannot enter the project.

Expected behavior

Ability to browse files in self-hosted sharelatex projects.

How To Reproduce

Install version 0.5.3 and above, add a self-hosted server and log in, then try to enter any of the listed projects to reproduce.

Environment

[Optional] Developer Logs

Error: Error: unexpected server response (502) at SocketNamespace. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\api\socketio.js:70:19) at EventEmitter.emit [as $emit] (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\socket.io-client\lib\events.js:165:15) at Socket.publish (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\socket.io-client\lib\socket.js:103:19) at Socket.onError (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\socket.io-client\lib\socket.js:485:10) at WS.onError (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\socket.io-client\lib\transports\websocket.js:148:17) at websocket.onerror (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\socket.io-client\lib\transports\websocket.js:82:12) at WebSocket.onError (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\ws\lib\WebSocket.js:452:14) at WebSocket.emit (node:events:513:28) at ClientRequest.response (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\ws\lib\WebSocket.js:721:12) at Object.onceWrapper (node:events:628:26) at ClientRequest.emit (node:events:525:35) at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:701:27) at HTTPParser.parserOnHeadersComplete (node:_http_common:119:17) at Socket.socketOnData (node:_http_client:542:22) at Socket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23) rejected promise not handled within 1 second: TypeError: Invalid host defined options stack trace: TypeError: Invalid host defined options at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\prettier\index.cjs:593:23) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at h (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:647) at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\intellisense\texDocFormatter.js:5:18) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at h (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:647) at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\intellisense\langIntellisenseProvider.js:9:27) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at h (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:647) at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\extension.js:10:36) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at require (node:internal/modules/cjs/helpers:110:18) at Function.i [as $nodeRequire] (d:\Microsoft VS Code\resources\app\out\vs\loader.js:5:98) at f.vb (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:30730) at async Promise.all (index 0) [iamhyc.overleaf-workshop]Invalid host defined options workbench.desktop.main.js:sourcemap:2017 TypeError: Invalid host defined options at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\node_modules\prettier\index.cjs:593:23) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at h (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:647) at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\intellisense\texDocFormatter.js:5:18) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at h (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:647) at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\intellisense\langIntellisenseProvider.js:9:27) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at h (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:647) at Object. (c:\Users\zy.vscode\extensions\iamhyc.overleaf-workshop-0.7.1\out\extension.js:10:36) at o._compile (d:\Microsoft VS Code\resources\app\out\vs\loader.js:4:1271) at Module._extensions..js (node:internal/modules/cjs/loader:1371:10) at Module.load (node:internal/modules/cjs/loader:1171:32) at Module._load (node:internal/modules/cjs/loader:1012:12) at f._load (node:electron/js2c/asar_bundle:2:13377) at c._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:171:5632) at n._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:29551) at t._load (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:133:35226) at Module.require (node:internal/modules/cjs/loader:1195:19) at require (node:internal/modules/cjs/helpers:110:18) at Function.i [as $nodeRequire] (d:\Microsoft VS Code\resources\app\out\vs\loader.js:5:98) at f.vb (d:\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:168:30730) at async Promise.all (index 0)

iamhyc commented 8 months ago

Thanks for the report. I will have a quick look at it now.

iamhyc commented 8 months ago

@fbotp I found there is no changes related to socket.io-client API between v0.5.2 and v0.5.3, except for an internal timeout exception which should not trigger 502 error.

Could you please attach the normal log starts with SocketIOAPI? Thank you.

iamhyc commented 8 months ago

I have just searched "502 error for socketio client" online and found this link maybe helpful:

https://stackoverflow.com/questions/35698595/bad-gateway-error-using-socket-io-node-js-over-ssl

Please check if your server address is correctly using "http://" or "https://". "http://" maybe wrong for SSL-enabled server.

fbotp commented 8 months ago

@iamhyc Thank you for your reply. Now I am using v0.5.2. When I enter the project called 面向战略性新兴产业的专名标引方法研究, the vscode log looks like this:

image

where 192.168.3.149:6180 is self-hosted server ,and if I use v0.5.3, the log looks like:

20240111191746 As you see, the error keeps reoccurring and doesn't stop

I think below picture shows that I have logged in. image

By the way, I'm sure my address is http://192.168.3.149:6180/. And if now I install v0.5.2 and reload window, files in project would appearred normally.

iamhyc commented 8 months ago

Got it. That is weird. I will check on sharelatex v4.2 later.

fbotp commented 8 months ago

thanks, waiting for your reply❤️

iamhyc commented 8 months ago

image

Cannot produce the bug on my side. I have to say this is really weird, especially considering there is no much difference between v0.5.2 and v0.5.3.

iamhyc commented 8 months ago

Can you try to remove the server firstly, then add the server and login to see if it works?

iamhyc commented 8 months ago

Though it is not able to reproduced, I find the server may prefer v2 connection by default.

Please have a try with the auto-generated temporary extension here: https://github.com/iamhyc/Overleaf-Workshop/actions/runs/7488723638?pr=75

It will use v2 connection if the error is thrown.

fbotp commented 8 months ago

I tried remove server and add again, I also use this temp extension, but it does't work, the error logs just like above. I suddenly remembered that I ran the following commands within the sharelatex container:

tlmgr option repository https://mirrors.tuna.tsinghua.edu.cn/CTAN/systems/texlive/tlnet
tlmgr update --self --all
tlmgr install scheme-full

I'm not sure if it will affect this.

fbotp commented 8 months ago

I rechecked all my operations: pulled sharelatex/sharelatex:4.2.0 from hub.docker.com using overleaf-toolkit, went into the container to install scheme-full, and created an admin user via launchpad , uploaded the project, then added the server in vscode, and tried to enter the project, and then found these error. Are there any operating errors?

iamhyc commented 8 months ago

I rechecked all my operations: pulled sharelatex/sharelatex:4.2.0 from hub.docker.com using overleaf-toolkit, went into the container to install scheme-full, and created an admin user via launchpad , uploaded the project, then added the server in vscode, and tried to enter the project, and then found these error. Are there any operating errors?

I did exactly the same thing, exccept to install scheme-full.

Can you test on just creating an example project?

iamhyc commented 8 months ago

Please also help test the new temporary extension and attach the log: https://github.com/iamhyc/Overleaf-Workshop/actions/runs/7489218302

I found I made some mistake in last one.

fbotp commented 8 months ago

5({(1X52_BCRH2T5R%~Q4RR I used this extension and 502 errors keep appearing.

Please also help test the new temporary extension and attach the log: https://github.com/iamhyc/Overleaf-Workshop/actions/runs/7489218302

I found I made some mistake in last one.

iamhyc commented 8 months ago

Ok, at least we know there is nothing to do with v2 api. The cause is still unknown.

fbotp commented 8 months ago

I'm trying to recreate a server without "scheme-full" to see if this has something to do with it

fbotp commented 8 months ago

I did these:

git clone https://github.com/overleaf/toolkit.git ./test
cd test
./bin/init
# then modify two variable in `config/overleaf.rc`, because server have no gui, and 80 port has another web server:
SHARELATEX_LISTEN_IP=0.0.0.0
SHARELATEX_PORT=6180

./bin/up

then visited http://192.168.3.149:6180/launchpad and create user, then created an example project named test, then added this server in vscode, and tried to enter this project. It still failed.

iamhyc commented 8 months ago

Then I believe you should blame your router or gateway. Though I still got no idea why v0.5.2 works ...

iamhyc commented 8 months ago

Just to make sure: have you tried http://127.0.0.1:6180?

fbotp commented 8 months ago

No, I ran this server on a linux server and visit it on my PC, so I don't know how to visited it by http://127.0.0.1:6180

iamhyc commented 8 months ago

No, I ran this server on a linux server and visit it on my PC, so I don't know how to visited it by http://127.0.0.1:6180

Use vscode SSH-Remote Extension and then install this extension in remote.

fbotp commented 8 months ago

I forawrd 6180 to PC localhost, and add server http://127.0.0.1:6180, it works, but why

iamhyc commented 8 months ago

I forawrd 6180 to PC localhost, and add server http://127.0.0.1:6180, it works, but why

I am not sure how you do the forward, but the websocket protocol maybe unstable in your environment. I guess.

fbotp commented 8 months ago

I found that, if I install extension on server, and connect to remote server by Remote-SSH first, then get into project, it works, if I connect to overleaf in a new vscode window, it will fail. So everytime I connect to overleaf, I need to ssh to server firstly?

iamhyc commented 8 months ago

I think the problem is: you can connect to the server via 127.0.0.1 but not 192.168.3.149.

In my network environment, I can connect to it via both 127.0.0.1 and 100.64.0.3 (virtual LAN address).

So, I don't think this is a general issue and I suggest you check your network router firstly.

fbotp commented 8 months ago

~But I feel a little strange, why can I access it through the web page but not through vscode? And there will be no problem logging in, getting the project list, creating a new project, or deleting the project.~ Ok, it's my pc problem, thank you. So sorry to bother you.

iamhyc commented 8 months ago

But I feel a little strange, why can I access it through the web page but not through vscode? And there will be no problem logging in, getting the project list, creating a new project, or deleting the project.

You make the reply so fast and I am still typing ...

Could you also let me know why? I am still curious about the difference between v0.5.2 and v0.5.3

fbotp commented 8 months ago

Sorry, I installed v2rayA on my PC, and use system proxy mode, and config RoutingA as below:

default: direct domain(arxiv.org)->proxy domain(debrepo.freedownloadmanager.org)->proxy domain(files.pythonhosted.org)->proxy domain(geosite:docker)->proxy domain(geosite:facebook)->proxy domain(geosite:github)->proxy domain(geosite:google)->proxy domain(geosite:medium)->proxy domain(geosite:openai)->proxy domain(geosite:quora)->proxy domain(geosite:reddit)->proxy domain(geosite:stackexchange)->proxy domain(huggingface.co)->proxy domain(ppa.launchpadcontent.net)->proxy domain(pypi.org)->proxy domain(steamcommunity.com)->proxy domain(steampowered.com)->proxy domain(steamunlocked.net)->proxy domain(geosite:twitter)->proxy domain(geosite:v2ray)->proxy domain(v2ex.com)->proxy domain(v2raya.org)->proxy domain(www.popai.pro)->proxy domain(chat.forefront.ai)->proxy domain(geosite:wikimedia)->proxy

It seems that, if I set network proxy in windows, it does't work, but if I close it in Windows settings, it will be okay.

I just found that, even if I set all domain as direct mode, this extension still doesn't work. It's so strange. Anyway, thanks a lot!

iamhyc commented 8 months ago

Yes, I should have warned you of the proxy thing firstly. Anyway, glad that you find the root cause!

fbotp commented 8 months ago

Yes, I changed http.proxy support to off in vscode, and everything works fine! Thank you for your patient answer!