Skip to content
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

Fix Web Debugging and Other Websocket Endpoints with Metro 0.67 #1560

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: stop using stubs for isDebuggerConnected and broadcast
  • Loading branch information
thymikee committed Feb 18, 2022
commit 4228899c5da623ec9d6894f832c4cffd5d91d784
19 changes: 8 additions & 11 deletions packages/cli-server-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ type MiddlewareOptions = {
};

export function createDevServerMiddleware(options: MiddlewareOptions) {
let isDebuggerConnected = () => false;
let broadcast = (_event: any) => {};
const debuggerProxyEndpoint = createDebuggerProxyEndpoint();
const isDebuggerConnected = debuggerProxyEndpoint.isDebuggerConnected;

const messageSocketEndpoint = createMessageSocketEndpoint();
const broadcast = messageSocketEndpoint.broadcast;

const eventsSocketEndpoint = createEventsSocketEndpoint(broadcast);

const middleware = connect()
.use(securityHeadersMiddleware)
Expand All @@ -47,7 +52,7 @@ export function createDevServerMiddleware(options: MiddlewareOptions) {
.use('/debugger-ui', debuggerUIMiddleware())
.use(
'/launch-js-devtools',
devToolsMiddleware(options, () => isDebuggerConnected()),
devToolsMiddleware(options, isDebuggerConnected),
)
.use('/open-stack-frame', openStackFrameInEditorMiddleware(options))
.use('/open-url', openURLMiddleware)
Expand All @@ -65,14 +70,6 @@ export function createDevServerMiddleware(options: MiddlewareOptions) {
middleware.use(serveStatic(folder));
});

const debuggerProxyEndpoint = createDebuggerProxyEndpoint();
isDebuggerConnected = debuggerProxyEndpoint.isDebuggerConnected;

const messageSocketEndpoint = createMessageSocketEndpoint();
broadcast = messageSocketEndpoint.broadcast;

const eventsSocketEndpoint = createEventsSocketEndpoint(broadcast);

return {
websocketEndpoints: {
'/debugger-proxy': debuggerProxyEndpoint.server,
Expand Down