-
Notifications
You must be signed in to change notification settings - Fork 0
Disable WebSocket by default (opt-in via ENABLE_WEBSOCKET) #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,13 @@ const fs = require('fs'); | |
| const fsp = fs.promises; | ||
| const path = require('path'); | ||
| const url = require('url'); | ||
| // Try to load WebSocket module, fallback if not available | ||
| // WebSocket support is opt-in. Set ENABLE_WEBSOCKET=true to enable the optional | ||
| // /ws channel and POST /message broadcasting. It is disabled by default because | ||
| // the API Simulator UI communicates over plain HTTP and does not use WebSockets. | ||
| const WEBSOCKET_ENABLED = process.env.ENABLE_WEBSOCKET === 'true'; | ||
| let WebSocket = null; | ||
| let isWebSocketAvailable = false; | ||
| if (WEBSOCKET_ENABLED) { | ||
|
Comment on lines
+26
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Separate “disabled by config” from “ws unavailable”. This gate reuses Also applies to: 38-40 🤖 Prompt for AI Agents |
||
| try { | ||
| WebSocket = require('ws'); | ||
| isWebSocketAvailable = true; | ||
|
|
@@ -31,6 +35,9 @@ console.log('WebSocket support enabled'); | |
| console.log('WebSocket support disabled (ws package not installed)'); | ||
| console.log('Install with: npm install ws'); | ||
| } | ||
| } else { | ||
| console.log('WebSocket support disabled (set ENABLE_WEBSOCKET=true to enable)'); | ||
| } | ||
| const DIST_DIR = path.join(__dirname, 'dist'); | ||
| const DATA_DIR = path.join(__dirname, '.api-sim-data'); | ||
| const EVENTS_FILE = path.join(DATA_DIR, 'events.jsonl'); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Don't hardcode the client gate to
false.With this literal, enabling
ENABLE_WEBSOCKET=trueon the server still never re-enables the browser connection, so the opt-in flow described in this PR cannot work end to end. Read the flag from shared runtime/build config instead of baking infalse.🤖 Prompt for AI Agents