-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Dynamically webview resources fail to load in some browser/OS combinations #3410
Comments
So this happens even with a valid certificate when you don't get any certificate errors right? Could you post the browser log when you try this with a valid certificate? I wonder if the resources are getting blocked by CSP or something. |
Yes.
Here are the logs, I didn't see any other warning or errors related to certificate except these, seems there are no useful information about these errors, they just show net::ERR_FAILED after pending for several minutes . |
Hmm yeah you're right that doesn't look useful at all. Is this extension public so I can test it out? Or if not would you be able to make an example extension that reproduces the issue? |
With the latest code-server and valid certificate,I still can't load resources dynamically on webview. The example extension repo is here, you can download extension from here, this extension is just a little modified from vscode-webview-sample. Steps to Reproduce:
Expectedget "hello wrold test.js" from console, which means test.js is loaded successfully. Actualtest.js is keep pending , and get a net::ERR_FAILED error finally. ScreenshotPossible problemsThe requested resource test.js without cookies(Not sure). Please let me know if you have any ideas! |
I am sure it is related to service-worker in when I use localhost with self-signed certificate, I got an error "could not register service workers", service workers will not be used in this scene. So that loading resources dynamically works fine. With an valid certificate, service workers can be registered,when loading resources dynamically, eventListener "fetch" in service-worker.js will be triggered, there maybe something wrong here. |
Ahhhhhh I haven't had a chance to try the example yet but that makes a lot of sense. If I recall correctly VS Code intercepts requests from the web view (which is an iframe) using the service worker and routes them through the parent frame instead. I think you're right that something must be wrong there. |
Interesting, I don't get this on Linux + Firefox/Chromium but I do get this on Windows + Chrome. |
Windows+Firefox also works,so this problem may be related to the browser? Do you know there are other ways to avoid this problem?Or other ways to dynamically load resources? |
I haven't debugged yet to see where exactly the issue lies but I think there must be some combination of the service worker and browser that is causing a problem. At the moment I can't think of any workarounds other than somehow avoiding dynamically loaded resources. 😞 We'll need to do more testing. |
I had similar problem with latest release 3.10, had to downgrade to 3.8. |
I also met the same issue with the latest version 3.11.1. We need to downgrade to 3.8.1 to work correctly |
@Kaka1127 this should be fixed in the next release! |
It was good to know! |
Well...originally, I was thinking this was related to the service worker path (which we messed up when we refactored something things) 🤔
But...now I'm seeing this comment, which could mean that the issue is related to this: #2760 I guess we'll have to test in the next release and see if it's still an issue but I'm hoping it's fixed 🤞 |
@jsjoeio |
Ah, I think you mean 3.12.0. Thanks for testing! We have to prioritize some other things (improving the build and release process) but I will add it to the release after that! (Adding to On Deck for now) |
If someone else has time to poke around and see what a fix might be though, then that would help us address this faster! I just don't have the bandwidth for this next version milestone |
I updated the issue title, just FYI for anyone following this if you are having the |
same issue , will it fixed in next version ? |
@DevXiaolan I see you downvoted that comment. Are you seeing a different error? |
I dont think I could get it working over http either. |
Fixes coder#3410 Fixes coder#4604 Fixes coder#4607 Fixes coder#4608 Fixes coder#4609 Also has the foundation for coder#4619.
verison 4.0.1 still meet the same issue, by the way my browser is Chrome96.0.4664.110. |
@dantegarden thanks for testing! Can you post basic repro steps? |
version 4.2.0\4.3.0\4.4.0 still meet the same issue, by the way my browser is Microsoft Edge 101.0.1210.47 and Chrome 101.0.4951.64.But it’s ok in Firefox 100.0.1 and both browser didn’t change any security config. Environment: ——————————————————————— Error: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope ('https://172.20.23.102/static/out/vs/workbench/contrib/webview/browser/pre/') with script ('https://172.20.23.102/static/out/vs/workbench/contrib/webview/browser/pre/service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-webview.net&remoteAuthority=172.20.23.102'): An SSL certificate error occurred when fetching the script.. |
@hhc87 any chance you can post repro steps? Last time I looked into this I couldn't reproduce |
@jsjoeio very happy to get your reply I use docker to deploy the 4.4.0 version of code-server (offline environment) on centos7, and then install the plugin 'form generator plugin' developed by jakHuang through offline installation (can be obtained in the vscode app store), and the plugin's The remote connection address is configured as the same-origin address exposed by the code-server (eg: https://172.20.23.102/code-server and https://172.20.23.102/formgenerator ), meanwhile, the https certificate is issued locally by the linux server Generated certificate. The problem is that when I right-click the .vue file in the workspace and click 'Enter Form Designer', the code-server will report an error, and the error message is as follows: Error: Could not register service workers: SecurityError: Failed to register a ServiceWorker for scope ('https://172.20.23.102/static/out/vs/workbench/contrib/webview/browser/pre/') with script ('https://172.20.23.102/static/out/vs/workbench/contrib/webview/browser/pre/service-worker.js?v=4&vscode-resource-base-authority=vscode-resource.vscode-webview.net&remoteAuthority=172.20.23.102'): An SSL certificate error occurred when fetching the script.. From the superficial exception information, it seems that the service worker does not recognize the self-created ssl certificate, and I don't know if it is allowed to use the service worker in the code-server which using the self-signed certificate. Hope to get your reply |
Thanks so much for the details! Do you know if it's possible to create a very minimal reproduction? I wonder if the issue is the SSL certificate 🤔 |
@jsjoeio |
@hhc87 okay awesome! Unfortunately, I don't give out my email for those kinds of things, but I am subscribed to the repo and check notifications M-F so I will respond here! |
Thank you for your patient reply, I created a small demo, the address is |
Just as a note: From several different dev. projects I can confirm, that Chrome or prop. all Chromium Browsers are rather strict and reject the usage of self signed certificates for service workers. @jsjoeio I think there is no way to fix this in code-server since this is a known behavior and discussed several times in the community (e.g. https://stackoverflow.com/questions/38728176/can-you-use-a-service-worker-with-a-self-signed-certificate) ... |
@hhc87 thank you for the demo repo and the info regarding the security of the issue! I will use that to try to reproduce this. I won't get to it for a couple weeks though fyi. @fritterhoff oh no! I wonder what we should do then 🤔 Do we update the docs, remove the self-signed certificate generation inside code-server, or something else? I think @code-asher and I will need to discuss this next month. |
Maybe that changed during some of the last releases but iirc chrome was rather picky. Maybe I find some time the next days to try it again 😉 |
hello, i also met with this problem, and my code-server version is 4.13.0. It's ok with a firefox(latest version), but failed with chrome or edge. Do you have some plan to deal with the problem? |
By the way, my client OS is windows~ |
No plans at the moment, I will need to find time to reproduce but it will be a while. |
its back again |
same issue again in 2024 |
I was able to resolve the issue by switching from Chrome to Firefox. With Firefox, Jupyter Notebooks load fine and run. I also installed the .crt file from the server into my Windows machine, which may have helped with the switch to Firefox. |
This still seems to be an issue. I have also had a look at multiple browsers and can confirm that it appears to be an issue with Chrome. On Firefox I do not get the problem. Thank you to @code-asher for pointing out that it worked on FireFox. |
Hi, I have two issues, they may all be related to https certificates.
code-server
prompt can‘t register serviceworker errorload resources dynamically
on my expansion webview.I run
code-server --host 0.0.0.0 --port 8223 --cert
in dockerubuntu:20.04
, and expose8223
in my Windows 10 host, but I get an ssl error when I open a exntesion webview in code-server in my company.when I use
Chrome command line
"--ignore-certificate-errors", my extension webview can't dynamic loading of resources(eg. js, css), which cause the page style confusion, the Chrome dev tool network display the resource keep pending until it fails.At first, I thought it was the invalid certificate problem,but even if I use a valid certificate, I still can't dynamic loading resources.(Without any certificate errors and any Chrome command line options)
I use something like this to dynamic loading resources
-->
OS/Web Information
code-server --version
: 3.9.0Steps to Reproduce
Expected
No error.
Actual
get an error in bottom right corner:
Screenshot
The text was updated successfully, but these errors were encountered: