vscode-jupyter: Race condition in port forwarding on Remote-Container on WSL

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Most upvoted comments

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.