-
Notifications
You must be signed in to change notification settings - Fork 22
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
Running Esbonio Preview on Codespaces doesn't work #896
Comments
Thank you for such a detailed issue report! Can I just check which version of the Esbonio extension you are using? While I've never tried Codespaces myself, I have been using the pre-release version of the extension ( Thanks also for finding |
Hi @alcarney thanks for the quick response. I've used the latest released version of the extension (v0.11.0). I installed v0.95.1 (pre-release). Now im getting the error/loading page of esbonio: After enabling debug logging, i can see the following output in my Esbonio log:
Which should be this line here:
After reloading the VsCode instance i get this output:
In both cases the "No Content found" loading/error page of esbonio doesn't change. opening another document just outputs the three lines from above . When im opening the preview (in this case on the container http://localhost:45525/) from outside (with the codespace url) im getting a semi-corrupt output of the html files. Multiple assets are missing (Images, Styles, and so on...). I also noticed, that the "build" folder is missing even if defined in config. I even removed the folder (from previous builds). It seams that the rst files are now transpiled on-the-fly? Idk. Running the build manually still works fine. All-In-All: I don't know where to start to debug further. Console outputs are looking ok for me. Only the Browser debug console outputs the following error: But this could be an error because something before that call goes wrong. |
Unfortunately, there are some differences in configuration between the two versions. If you haven't found it already, this page from the docs should tell you what you need to adapt your config to the pre-release version.
Looking at the screenshot, my guess is that the server hasn't run a full build yet... have you tried editing a file and saving it?
I don't immediately recognise those error messages 🤔... perhaps we can ignore those for now. |
I could be wrong, but those screenshots look like they are coming from the stable version? (
I'm hoping that would be enough to at least get the preview to show up... I'm worried getting the websocket connection the pre-release version uses for synchronised scrolling to also work however might be less straightforward... or maybe not? Can't quite get my head around how things in this case 😅 Anyway, I can add a call to |
Sorry you are right. After to many restarts it may have installed the rtm release again. The result is the same but im getting the new fancy "No Content Found" page again: Opening the url directly works fine & im getting my doc: In the browser log there is the illegal value for linenumber every time im navigating to a rst file again. Because you mentioned the websocket synchronized scrolling, this maybe is a follow-up problem. When i open the preview page im now also getting a csp error which could also be the issue: The vscode extension seems to also work with web sockets and the external uri handling and its only slighty different. Maybe that helps? https://github.com/microsoft/vscode-livepreview/blob/main/src/connectionInfo/connection.ts#L97 To the VSIX part: I did't tried it yet but it seems like there is support for that. |
I've opened #905 which will hopefully fix this however, I'm not able to test it myself. Are you able to download this vsix archive? It should contain a file |
Sadly this doesn't work :/ Ive googled a bit and also found this issues (any many references issues to that issue): microsoft/vscode-livepreview#111 Seems to be a general issue with codespaces (When opening the site for the firs time, there is a custom "loading" screen from github). But even when i open the url manually and then re-load or close & open the preview again it doesn't work. The line error message always appears when opening a new rst file (doesn't trigger again when im doing something with the preview). -> This may be also an issue but i think it isn't a problem for the preview which is my main importance. Idk what part of the preview process triggers the error (I don't know how to debug extensions proberly). But i found this line: esbonio/code/src/node/preview.ts Line 204 in 971fb91
Which maybe also leads to an error because of:
Maybe there are multiple references to localhost? I also forked your demo and add a devcontainer config. There i get the same error: Feel free to start a devcontainer from my fork. I pinned the version directly to the latest published preview. You can also uninstall the version and install the latest one from you via vsix. |
I tried, but for some reason it seems to crash out halfway through connecting... Despite what the error message says, I definitely have a working network connection 😅
Ah, forgot about the CSP 🤦♂️, yes that will definitely not help the situation. I've now made it so the CSP is derived from the result of You can find an updated version of the extension here |
That's frustrating :/ This missing nonce values are definitely a problem, without that script block the preview uri is never given to the iframe... 🤔 Like you I don't really know why the values are not there in the codespace, they seem to work as expected when the extension is run locally The issue I was having yesterday opening a codespace must be a Firefox issue, tried today with Chromium and it appears to work. I will see if I can figure out what is going on 🤞 |
I think I've found the root cause! The code that pushes the uri to preview into the // Control messages coming from the webview hosting this page
if (event.origin.startsWith("vscode-webview://")) {
// ...
viewer.src = message.show
// ...
}
}
// Control messages coming from the webpage being shown.
if (event.origin.startsWith("http://localhost:")) {
if (message.ready) {
// ...
vscode.postMessage({ ready: true })
}
} However, when running in Codespaces the webview message origin is something like So, now it's "just" a case of tracking down all the assumptions broken by Codespaces 😅 |
I think I've got it! Do you want to try the latest build and see if it works for you? Unfortunately, you will have to open the two port-forward links in a new tab and reopen the preview window before it will work though |
That looks very good. I can now see the preview in the demo fork & also in my custom repo. Opening the preview once in a seperate tab is the same workaroud as described here: microsoft/vscode-livepreview#111 Maybe we can use the same (upcoming?) fix from the vscode-livepreview plugin to also get it working with esbonio :D For now im very happy, because our users can view the preview. One thing to mention: Even if i open both tabs separetely im getting a endless loading panel here: This is mabe because of the following error: So there is the NaN line issue again. -> That isn't a blocking issue for us but its maybe also only a little problem? |
Glad to hear it!
I'll definitely be keeping an eye out 🤞
Has the server done a full rebuild of the docs yet? I had to change some of the JS esbonio injects into the build. That error looks like the old code might still be present.
To be honest, I don't think I saw that error when testing it myself... I'm hoping it's just a side effect of the WebSocket connection failing 😅 |
@alcarney Yea. I dind't remove the build dir. After removing it & reloading the window it works now as expected. Thank you again very much :) This helps a lot |
Expected behavior
The preview of a a rst file should be displayed.
Actual behavior
The Preview is broken.
The files are build and i can see a running process/automatically forwared port for esbonio:
The preview is generated from an iframe and i believe that the problem is, that the url to the html page is statically mapped to localhost:
Opening the preview in another tab served from the routed Codespace works as expected.
Its only the build-in preview tab in vscode which doesn't work.
I've investigated a little bit.
As far as i can interpret the current esbonio code localhost is hardcoded and there is some additional logic when serving via localhost or not. Therefore this should be the problem.
The VsCode LivePreview plugin uses the method:
asExternalUri
In the env object of vscode (sorry there was no direct hyperlink to the function. Just search for "asExternalUri"):
https://code.visualstudio.com/api/references/vscode-api#env
LivePreview Ref:
https://github.com/microsoft/vscode-livepreview/blob/main/src/connectionInfo/connection.ts#L85
Maybe this helps a bit. But ive never wrote a vscode plugin before. I din't find any other issues regarding Codespaces or Dev Containers.
Log output
(Optional) Settings from conf.py
No response
The text was updated successfully, but these errors were encountered: