Skip to content

Markdown Preview is not working #4421

Closed as not planned
Closed as not planned

Description

@benjcabalona1029

Issue is similar to #296 The fix in this issue is not applicable to me I think since I'm not running behind nginx.

  • Web Browser: Google Chrome
  • Local OS: Windows 10
  • Remote OS: Ubuntu 20.04

Steps to Reproduce

  1. Open any md file.
  2. Try previewing the document.

Nothing in the code-server logs, But on dev tools,

Uncaught (in promise) Error: Service Workers are not enabled. Webviews will not work. Try disabling private/incognito mode.
    at main.js:115
    at new Promise (<anonymous>)
    at main.js:115

I'm not accesing it in incognito mode.

Activity

  1. jsjoeio commented on Nov 1, 2021

    @jsjoeio
    Contributor

    @benjcabalona1029 you need to enable service workers in order for the markdown preview to work. Are you serving code-server via HTTPS?

  2. benjcabalona1029 commented on Nov 3, 2021

    @benjcabalona1029
    Author

    @jsjoeio Thank yor for your comment. How do i enable the service workers? No, I'm not serving it in https.

  3. jsjoeio commented on Nov 3, 2021

    @jsjoeio
    Contributor

    No, I'm not serving it in https

    There's your issue. You'll need to serve it via HTTPS and that will allow your browser to enable service workers automatically I believe.

  4. jsjoeio commented on Nov 3, 2021

    @jsjoeio
    Contributor

    I'm going to close this since this is related to your environment but feel free to open a Discussion if you need more help or have a question about enabling HTTPS. See the docs here for more info.

  5. benjcabalona1029 commented on Nov 4, 2021

    @benjcabalona1029
    Author

    Hi @jsjoeio I tried serving it with the --link for it to be served in HTTPS, however the preview is still not working.

    I get a new error,

      ERR [UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//"): Error: [UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")
        at b (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:77397)
        at new p (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:78038)
        at new m (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:79686)
        at Function.from (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:70:79103)
        at https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1271:14766
        at String.replace (<anonymous>)
        at _.rewriteVsCodeResourceUrls (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1271:14654)
        at _.set html [as html] (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1271:14307)
        at https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1226:30501
        at b.withWebview (https://benjcabalona-benjcabalona1029.cdr.co/static/b37ff28a0a582aee84a8f961755d0cb40a4081db/usr/lib/code-server/vendor/modules/code-oss-dev/out/vs/workbench/workbench.web.api.js:1226:31874)
  6. jsjoeio commented on Nov 4, 2021

    @jsjoeio
    Contributor

    Uhh...I have yet to see this error 🤔 @code-asher any ideas?

  7. code-asher commented on Nov 10, 2021

    @code-asher
    Member
  8. benjcabalona1029 commented on Nov 10, 2021

    @benjcabalona1029
    Author

    Okay, I'll try to update it once we have a new release. Can we reopen this issue? @jsjoeio

  9. jsjoeio commented on Nov 10, 2021

    @jsjoeio
    Contributor

    Good call! You got it

  10. krenny commented on Nov 11, 2021

    @krenny

    Might be unrelated but I have seen Issues like that while using private/incognito mode.

    For some odd reasons serverice workers won't start in incognito...

    Edit: this seems only be true for firefox

  11. jsjoeio commented on Nov 12, 2021

    @jsjoeio
    Contributor

    For some odd reasons serverice workers won't start in incognito...

    I believe service workers are disabled in incognito in Firefox (IIRC)

  12. austinbutler commented on Jan 19, 2022

    @austinbutler

    Markdown preview is also not working for me since upgrading to 4.0.1 it seems (from 3.x). I use SSH forwarding, and in the Chrome "Application" tab I see two service workers are green with status "activated and is running." Triggering markdown preview results in no new system logs or console logs, just shows "Activating Extensions..." then nothing happens.

    Console log
     INFO [Service Worker] registered
    webWorkerExtensionHost.ts:211 GET http://localhost:8081/static/stable/out/vs/workbench/services/extensions/worker/httpWebWorkerExtensionHostIframe.html?&vscodeWebWorkerExtHostId=f5c546d0-a5ec-4bbe-8289-7c3da99f2316 404 (Not Found)
    _startInsideIframe @ webWorkerExtensionHost.ts:211
    start @ webWorkerExtensionHost.ts:138
    Qr @ extensionHostManager.ts:124
    _createInstance @ instantiationService.ts:110
    createInstance @ instantiationService.ts:76
    g @ extensionHostManager.ts:57
    (anonymous) @ abstractExtensionService.ts:625
    _startExtensionHosts @ abstractExtensionService.ts:624
    _initialize @ abstractExtensionService.ts:521
    (anonymous) @ extensionService.ts:79
    Promise.then (async)
    Hl @ extensionService.ts:77
    _createInstance @ instantiationService.ts:110
    _createServiceInstance @ instantiationService.ts:230
    _createServiceInstanceWithOwner @ instantiationService.ts:219
    _createAndCacheServiceInstance @ instantiationService.ts:208
    _safeCreateAndCacheServiceInstance @ instantiationService.ts:151
    _getOrCreateServiceInstance @ instantiationService.ts:135
    _createInstance @ instantiationService.ts:88
    createInstance @ instantiationService.ts:76
    acquireInstantiationService @ configurationService.ts:457
    (anonymous) @ workbench.ts:212
    invokeFunction @ instantiationService.ts:61
    initServices @ workbench.ts:206
    startup @ workbench.ts:138
    open @ web.main.ts:103
    abstractExtensionService.ts:927 [ms-python.python]: Cannot register 'python.pythonPath'. This property is already registered.
    _logMessageInConsole @ abstractExtensionService.ts:927
    _handleExtensionPointMessage @ abstractExtensionService.ts:878
    X @ abstractExtensionService.ts:852
    _msg @ extensionsRegistry.ts:37
    warn @ extensionsRegistry.ts:50
    g @ configurationExtensionPoint.ts:237
    h @ configurationExtensionPoint.ts:212
    (anonymous) @ configurationExtensionPoint.ts:283
    _handle @ extensionsRegistry.ts:143
    acceptUsers @ extensionsRegistry.ts:134
    _handleExtensionPoint @ abstractExtensionService.ts:912
    _doHandleExtensionPoints @ abstractExtensionService.ts:858
    _scanAndHandleExtensions @ extensionService.ts:223
    await in _scanAndHandleExtensions (async)
    _initialize @ abstractExtensionService.ts:525
    await in _initialize (async)
    (anonymous) @ extensionService.ts:79
    Promise.then (async)
    Hl @ extensionService.ts:77
    _createInstance @ instantiationService.ts:110
    _createServiceInstance @ instantiationService.ts:230
    _createServiceInstanceWithOwner @ instantiationService.ts:219
    _createAndCacheServiceInstance @ instantiationService.ts:208
    _safeCreateAndCacheServiceInstance @ instantiationService.ts:151
    _getOrCreateServiceInstance @ instantiationService.ts:135
    _createInstance @ instantiationService.ts:88
    createInstance @ instantiationService.ts:76
    acquireInstantiationService @ configurationService.ts:457
    (anonymous) @ workbench.ts:212
    invokeFunction @ instantiationService.ts:61
    initServices @ workbench.ts:206
    startup @ workbench.ts:138
    open @ web.main.ts:103
    await in open (async)
    fe @ web.main.ts:413
    n @ workbench.web.api.ts:664
    (anonymous) @ workbench.ts:565
    (anonymous) @ workbench.ts:603
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    o @ loader.js:1709
    _ @ loader.js:2208
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    v @ loader.js:1871
    (anonymous) @ workbench.nls.js:7
    abstractExtensionService.ts:927 [ms-python.python]: Cannot register 'python.venvPath'. This property is already registered.
    _logMessageInConsole @ abstractExtensionService.ts:927
    _handleExtensionPointMessage @ abstractExtensionService.ts:878
    X @ abstractExtensionService.ts:852
    _msg @ extensionsRegistry.ts:37
    warn @ extensionsRegistry.ts:50
    g @ configurationExtensionPoint.ts:237
    h @ configurationExtensionPoint.ts:212
    (anonymous) @ configurationExtensionPoint.ts:283
    _handle @ extensionsRegistry.ts:143
    acceptUsers @ extensionsRegistry.ts:134
    _handleExtensionPoint @ abstractExtensionService.ts:912
    _doHandleExtensionPoints @ abstractExtensionService.ts:858
    _scanAndHandleExtensions @ extensionService.ts:223
    await in _scanAndHandleExtensions (async)
    _initialize @ abstractExtensionService.ts:525
    await in _initialize (async)
    (anonymous) @ extensionService.ts:79
    Promise.then (async)
    Hl @ extensionService.ts:77
    _createInstance @ instantiationService.ts:110
    _createServiceInstance @ instantiationService.ts:230
    _createServiceInstanceWithOwner @ instantiationService.ts:219
    _createAndCacheServiceInstance @ instantiationService.ts:208
    _safeCreateAndCacheServiceInstance @ instantiationService.ts:151
    _getOrCreateServiceInstance @ instantiationService.ts:135
    _createInstance @ instantiationService.ts:88
    createInstance @ instantiationService.ts:76
    acquireInstantiationService @ configurationService.ts:457
    (anonymous) @ workbench.ts:212
    invokeFunction @ instantiationService.ts:61
    initServices @ workbench.ts:206
    startup @ workbench.ts:138
    open @ web.main.ts:103
    await in open (async)
    fe @ web.main.ts:413
    n @ workbench.web.api.ts:664
    (anonymous) @ workbench.ts:565
    (anonymous) @ workbench.ts:603
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    o @ loader.js:1709
    _ @ loader.js:2208
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    v @ loader.js:1871
    (anonymous) @ workbench.nls.js:7
    mime.ts:64 Overwriting extension <<.hbs>> to now point to mime <<text/x-handlebars>>
    (anonymous) @ mime.ts:64
    v @ mime.ts:58
    _mergeLanguage @ languagesRegistry.ts:191
    _registerLanguage @ languagesRegistry.ts:165
    _registerLanguages @ languagesRegistry.ts:120
    _initializeFromRegistry @ languagesRegistry.ts:114
    (anonymous) @ languagesRegistry.ts:96
    fire @ event.ts:577
    setDynamicLanguages @ modesRegistry.ts:50
    (anonymous) @ workbenchModeService.ts:139
    _handle @ extensionsRegistry.ts:143
    acceptUsers @ extensionsRegistry.ts:134
    _handleExtensionPoint @ abstractExtensionService.ts:912
    _doHandleExtensionPoints @ abstractExtensionService.ts:858
    _scanAndHandleExtensions @ extensionService.ts:223
    await in _scanAndHandleExtensions (async)
    _initialize @ abstractExtensionService.ts:525
    await in _initialize (async)
    (anonymous) @ extensionService.ts:79
    Promise.then (async)
    Hl @ extensionService.ts:77
    _createInstance @ instantiationService.ts:110
    _createServiceInstance @ instantiationService.ts:230
    _createServiceInstanceWithOwner @ instantiationService.ts:219
    _createAndCacheServiceInstance @ instantiationService.ts:208
    _safeCreateAndCacheServiceInstance @ instantiationService.ts:151
    _getOrCreateServiceInstance @ instantiationService.ts:135
    _createInstance @ instantiationService.ts:88
    createInstance @ instantiationService.ts:76
    acquireInstantiationService @ configurationService.ts:457
    (anonymous) @ workbench.ts:212
    invokeFunction @ instantiationService.ts:61
    initServices @ workbench.ts:206
    startup @ workbench.ts:138
    open @ web.main.ts:103
    await in open (async)
    fe @ web.main.ts:413
    n @ workbench.web.api.ts:664
    (anonymous) @ workbench.ts:565
    (anonymous) @ workbench.ts:603
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    o @ loader.js:1709
    _ @ loader.js:2208
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    v @ loader.js:1871
    (anonymous) @ workbench.nls.js:7
    mime.ts:64 Overwriting extension <<.handlebars>> to now point to mime <<text/x-handlebars>>
    (anonymous) @ mime.ts:64
    v @ mime.ts:58
    _mergeLanguage @ languagesRegistry.ts:191
    _registerLanguage @ languagesRegistry.ts:165
    _registerLanguages @ languagesRegistry.ts:120
    _initializeFromRegistry @ languagesRegistry.ts:114
    (anonymous) @ languagesRegistry.ts:96
    fire @ event.ts:577
    setDynamicLanguages @ modesRegistry.ts:50
    (anonymous) @ workbenchModeService.ts:139
    _handle @ extensionsRegistry.ts:143
    acceptUsers @ extensionsRegistry.ts:134
    _handleExtensionPoint @ abstractExtensionService.ts:912
    _doHandleExtensionPoints @ abstractExtensionService.ts:858
    _scanAndHandleExtensions @ extensionService.ts:223
    await in _scanAndHandleExtensions (async)
    _initialize @ abstractExtensionService.ts:525
    await in _initialize (async)
    (anonymous) @ extensionService.ts:79
    Promise.then (async)
    Hl @ extensionService.ts:77
    _createInstance @ instantiationService.ts:110
    _createServiceInstance @ instantiationService.ts:230
    _createServiceInstanceWithOwner @ instantiationService.ts:219
    _createAndCacheServiceInstance @ instantiationService.ts:208
    _safeCreateAndCacheServiceInstance @ instantiationService.ts:151
    _getOrCreateServiceInstance @ instantiationService.ts:135
    _createInstance @ instantiationService.ts:88
    createInstance @ instantiationService.ts:76
    acquireInstantiationService @ configurationService.ts:457
    (anonymous) @ workbench.ts:212
    invokeFunction @ instantiationService.ts:61
    initServices @ workbench.ts:206
    startup @ workbench.ts:138
    open @ web.main.ts:103
    await in open (async)
    fe @ web.main.ts:413
    n @ workbench.web.api.ts:664
    (anonymous) @ workbench.ts:565
    (anonymous) @ workbench.ts:603
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    o @ loader.js:1709
    _ @ loader.js:2208
    i._invokeFactory @ loader.js:1185
    i.complete @ loader.js:1195
    i._onModuleComplete @ loader.js:1821
    i._onModuleComplete @ loader.js:1833
    i._resolve @ loader.js:1781
    i.defineModule @ loader.js:1424
    v @ loader.js:1871
    (anonymous) @ workbench.nls.js:7
    I @ console.ts:137
    $logExtensionHostMessage @ mainThreadConsole.ts:39
    _doInvokeHandler @ rpcProtocol.ts:472
    _invokeHandler @ rpcProtocol.ts:457
    _receiveRequest @ rpcProtocol.ts:373
    _receiveOneMessage @ rpcProtocol.ts:295
    (anonymous) @ rpcProtocol.ts:160
    fire @ event.ts:577
    fire @ ipc.net.ts:511
    _receiveMessage @ ipc.net.ts:869
    (anonymous) @ ipc.net.ts:708
    fire @ event.ts:577
    acceptChunk @ ipc.net.ts:284
    (anonymous) @ ipc.net.ts:245
    (anonymous) @ browserSocketFactory.ts:197
    fire @ event.ts:577
    C._fileReader.onload @ browserSocketFactory.ts:81
    webWorkerExtensionHost.ts:184 The Web Worker Extension Host did not start in 60s, that might be a problem.
    

    Not sure if related or a new issue.

  13. tlw-ray commented on Feb 9, 2022

    @tlw-ray

    When use http://127.0.0.1 or http://localhost code-server's markdown-preview-enhanced preview should worked fine, otherwise use http://ip markdown-preview-enhanced preview is not working.

    VSCode markdown Plugin: shd101wyy.markdown-preview-enhanced
    Explorer: firefox or chrome
    CodeServer: v4.0.2

  14. 11 remaining items

  15. jsjoeio commented on Feb 24, 2022

    @jsjoeio
    Contributor

    @Cleanairdreaming are you using HTTPS?

  16. ksbalajee commented on Jul 14, 2022

    @ksbalajee

    Hi @jsjoeio ,
    I'm trying to build a react application with the code server as an iframe. The code server is served over HTTPS and when I tried to launch my react application in my local (http://localhost:3000), I don't see any issues. However, when I deploy my react application to a domain (http://my-app.com) that's when I'm getting the error that the OP posted and also a popup saying that
    code-server is being accessed in an insecure context. Web views, the clipboard, and other functionality may not work as expected.
    Also when I try to open the code server URL from the iframe to a new tab, I don't see this issue. Do I need to host my react application in HTTPS as well?

    image

    code-server: v4.3.0
    Code: 1.65.2
    Commit: Unknown
    Date: 2022-04-14T21:04:05.402Z
    Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

  17. jsjoeio commented on Jul 18, 2022

    @jsjoeio
    Contributor

    Can you deploy it to HTTPS? I believe many services offer this for free. Other than that, there isn't much we can do since this is a browser limitation

  18. gogobd commented on Jul 19, 2022

    @gogobd

    Maybe #5338 is related?

  19. ksbalajee commented on Jul 31, 2022

    @ksbalajee

    Can you deploy it to HTTPS? I believe many services offer this for free. Other than that, there isn't much we can do since this is a browser limitation

    I deployed it in HTTPS and it works as expected. Thanks @jsjoeio

  20. jsjoeio commented on Aug 1, 2022

    @jsjoeio
    Contributor

    awesome! i'm going to close this for now then.

  21. weironz commented on Aug 4, 2022

    @weironz
  22. gogobd commented on Aug 4, 2022

    @gogobd

    Is it just not planned to allow code server to work properly with the certificates it creates when started with ’--cert’?

  23. Water-Ghost commented on Aug 4, 2022

    @Water-Ghost

    @jsjoeio It worked, when I add --cert. The link worked perfectly when use safari, the only thing need to do is to trust the certificat. Chrome not worked, I turn to Chrome Canary, and start it with --ignore-certificate-errors --ignore-urlfetcher-cert-request, finally it worked.

  24. gogobd commented on Aug 4, 2022

    @gogobd

    The certs are being created with mkcert i wonder if chrome starts to work if you install mkcert on your host system?

  25. code-asher commented on Aug 10, 2022

    @code-asher
    Member

    By working properly do we mean Chrome is not letting you accept the self-signed certificate? When I try I get "your connection is not private" (as expected) then I can accept the certificate anyway by going to advanced > proceed on the page.

  26. gogobd commented on Aug 10, 2022

    @gogobd

    When i do "advanced.../proceed..." i still get webview errors and most cool features don't work as expected :-/

  27. code-asher commented on Aug 10, 2022

    @code-asher
    Member

    Ohhhhh right I remember now that Chrome started rejecting the certificate for service workers even if you accept the certificate on that page. I am not sure if there is anything we can do from code-server's side on this unfortunately. I think this is just a decision they made on the browser side so we are kinda stuck with it.

    It might be wise to output some text when using --cert describing the limitations or maybe show a message in-browser if we can about the issue. Or maybe the move is to deprecate --cert and recommend something like mkcert?

    Although personally to me it feels like a bug so maybe there is something upstream about it.

  28. code-asher commented on Aug 10, 2022

    @code-asher
    Member

    Interestingly Firefox does seem to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions