Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Race condition when setting up a shim for socket.io #2069

Description

@ojarjur

There is a race condition bug in the way we setup socket.io when we are replacing the native WebSocket implementation (which is necessary when connecting from Cloud Shell).

The issue is that our websocket.js code, which replaces the native window.WebSocket with our shim, runs after the main.min.js code, which creates the Kernel object.

The Kernel code does not directly call window.WebSocket. Instead, it copies the value of window.WebSocket at the time it was created into a field of the object, and then calls the value of that field.

This means that if we replace the window.WebSocket value before the Kernel object gets created, then our shim works as expected. However, if that replacement does not happen until the Kernel object is created, then the shim will not work.

We have two options to fix this:

  1. Ensure the websocket.js code runs before the main.min.js code
    or
  2. Make the websocket.js code modify the field in the Kernel object.

I'm not sure if the second option is even possible, so I think the first is by far the best choice.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions