fregante / fregante/GhostText

Reuse HTTP port for WebSocket

Open
#272 1 comment 0 reactions 0 assignees View on GitHub
enhancement help wanted sublime-text
Dominant language
JavaScript
Stars
3.6k
Forks
133
PR merge metrics
No merged PRs in 30d

Description

Findings:

- There's no need to create a new WebSocket server for every connection
- WebSocket servers can live on the same connection as HTTP servers

Changes suggested:

- Have the HTTP server return a static response: `{ProtocolVersion: 1, WebSocketPort: 4001}` (the port is still user-configurable)
- Move the connection logic behind the WebSocket instead of the HTTP server, because in the future the browser extension will be able to skip the HTTP request

This change is backwards-compatible in editor extensions, it can already be seen in the new VS Code extension: https://github.com/fregante/GhostText-for-VSCode/blob/17a6d24f066aef98c2561b8690592c08e5c8c6ff/source/extension.ts#L120-L122

I think the ACME plugin has also been doing this for years: https://github.com/fhs/Ghost/blob/aaff3cd0ec26f69a7f6bc59e8a419fafa5d7aa6d/main.go#L80

Contributor guide

Open the contributing guide

Research direction

Start by locating the HTTP server and WebSocket connection entry points, then compare the linked VS Code extension.ts and ACME plugin main.go examples. Done means the HTTP server returns the stated static response, the WebSocket reuses the configurable port, connection logic is behind WebSocket, and editor extensions remain compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.