question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Race condition in port forwarding on Remote-Container on WSL

See original GitHub issue

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

I’m using Bokeh and Holoviews to render a chart that opens a connection back to a websocket.

A race condition exists between the backend Tornado server starting up and the port being forwarded, to making the first HTTP request. Re-running the cell repeatedly either results in a chart being displayed or no chart being displayed.

VS Code Version

1.71.1

Jupyter Extension Version

v2022.8.1002431955

Jupyter logs

Rather than pasting the Jupyter logs, here are the Developer Console javascript logs:

Startup

INFO [attempt 1] Invoking resolveAuthority(dev-container)
log.ts:301  INFO [attempt 1] resolveAuthority(dev-container) returned '127.0.0.1:35017' after 4479 ms
VM11:4 Registering custom require.js for Jupyter Kernel
eval @ VM11:4
notebookWebviewPreloads.js:3 Notebook preload (https://vscode-remote%2Bdev-002dcontainer-002b633a5c7372635c6a6f686e6e792d726f626f745c4572676f6e2e52657365617263685c656d725c646174615c6175676d656e745c4e42424f.vscode-resource.vscode-cdn.net/home/vscode/.vscode-server/extensions/ms-toolsai.jupyter-2022.8.1002431955/out/node_modules/%40vscode/jupyter-ipywidgets/dist/ipywidgets.js) looks like a module but does not export an activate function
r @ notebookWebviewPreloads.js:3
console.ts:137 [Extension Host] Starting WebSocket: RAW/api/kernels/f1213451-2417-49ab-89f2-71c059f9c919
DevTools failed to load source map: Could not load content for https://vscode-remote+dev-002dcontainer-002b633a5c7372635c6a6f686e6e792d726f626f745c4572676f6e2e52657365617263685c656d725c646174615c6175676d656e745c4e42424f.vscode-resource.vscode-cdn.net/home/vscode/.vscode-server/extensions/ms-toolsai.jupyter-2022.8.1002431955/out/webviews/webview-side/ipywidgetsKernel/ipywidgetsKernel.js.map: Connection error: net::ERR_NAME_NOT_RESOLVED

No chart displayed

VM22:343 [bokeh] setting log level to: 'info'
The FetchEvent for "http://localhost:36281/autoload.js?bokeh-autoload-element=1002&bokeh-absolute-url=http://localhost:36281&resources=none" resulted in a network error response: the promise was rejected.
Promise.then (async)
(anonymous) @ service-worker.js:213
service-worker.js:352          Uncaught (in promise) TypeError: Failed to fetch
    at l (service-worker.js:352:11)
l @ service-worker.js:352
VM26:12          GET http://localhost:36281/autoload.js?bokeh-autoload-element=1002&bokeh-absolute-url=http://localhost:36281&resources=none net::ERR_FAILED
(anonymous) @ VM26:12
(anonymous) @ VM26:13
domEval @ index.js:1304
renderHTML @ index.js:1317
renderOutputItem @ index.js:1447
render @ notebookWebviewPreloads.js:3
renderOutputCell @ notebookWebviewPreloads.js:3
await in renderOutputCell (async)
(anonymous) @ notebookWebviewPreloads.js:3
te.outputs.set.queue @ notebookWebviewPreloads.js:3
enqueue @ notebookWebviewPreloads.js:3
(anonymous) @ notebookWebviewPreloads.js:3
postMessage (async)
(anonymous) @ index.html?id=d051151b-29f8-40da-ba40-2da365b2934e&origin=d051151b-29f8-40da-ba40-2da365b2934e&swVersion=4&extensionId=&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app&remoteAuthority=dev-container%2B633a5c7372635c6a6f686e6e792d726f626f745c4572676f6e2e52657365617263685c656d725c646174615c6175676d656e745c4e42424f&purpose=notebookRenderer:1102
HostMessaging.channel.port1.onmessage @ index.html?id=d051151b-29f8-40da-ba40-2da365b2934e&origin=d051151b-29f8-40da-ba40-2da365b2934e&swVersion=4&extensionId=&platform=electron&vscode-resource-base-authority=vscode-resource.vscode-cdn.net&parentOrigin=vscode-file%3A%2F%2Fvscode-app&remoteAuthority=dev-container%2B633a5c7372635c6a6f686e6e792d726f626f745c4572676f6e2e52657365617263685c656d725c646174615c6175676d656e745c4e42424f&purpose=notebookRenderer:295

Chart displays and is interactive

VM22:343 [bokeh] setting log level to: 'info'
VM22:746 [bokeh] Websocket connection 0 is now open
VM22:324 [bokeh] document idle at 69 ms
VM22:322 Bokeh items were rendered successfully

Coding Language and Runtime Version

Python v3.9.13, holoviews 1.15.0, hvplot 0.8.1, bokeh 2.4.3

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Remote

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ddrinkacommented, Sep 22, 2022

I’ve done enough issue-hijacking. I’ll jump over to Bokeh’s issue tracking for further conversation about Bokeh and VSCode using the default transport, and leave this issue to track any additional thoughts on the race condition when Bokeh is running in Server mode.

Thanks for your input @bryevdv, appreciate the response here.

0reactions
DonJayamannecommented, Sep 25, 2022

Summary for internal (personal notes):

I’m going to close this as something that cannot be fixed in VS Code as this is specific to bokeh package. However if ther’es something we (Jupyter extension or VS Code) can do to resolve this, please do comment here or create a new issue

Closing this for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WSL Port Forwarding - DEV Community ‍ ‍
When you start a server in WSL, both Windows and Linux share the same local host. ... you need to port forward the...
Read more >
WSL+Docker: Kubernetes on the Windows Desktop
Below, we will cover in brief how to install and use various solutions to run Kubernetes locally.
Read more >
Docker - CS156 - UCSB CS156 - GitHub Pages
Virtualization/Container platform. ... dev_environment multiple times quickly, there is a race condition which causes the command to open up the same bash ...
Read more >
Posts by Tag - snowscan.io
We get to play with ESI template injection to get the initial shell, then abuse a race condition in a PHP script so...
Read more >
0xdf hacks stuff | CTF solutions, malware analysis, home lab ...
From there, I'll get root in that container, and then abuse CVE-2022-0492 to get root ... attack to get a foothold and a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found