Skip to content

Commit 22a87e0

Browse files
Hypukfacebook-github-bot
authored andcommitted
Change default Inspector Proxy port to 8081
Reviewed By: cwdick Differential Revision: D14745974 fbshipit-source-id: f4b3b158f55c6f5f1b3d9cc2528c5ddb59774a8b
1 parent 716c298 commit 22a87e0

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

packages/metro-inspector-proxy/src/InspectorProxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class InspectorProxy {
4242
// Internal counter for device IDs -- just gets incremented for each new device.
4343
_deviceCounter: number = 0;
4444

45-
// We store server's address with port (like '127.0.0.1:8082') to be able to build URLs
45+
// We store server's address with port (like '127.0.0.1:8081') to be able to build URLs
4646
// (devtoolsFrontendUrl and webSocketDebuggerUrl) for page descriptions. These URLs are used
4747
// by debugger to know where to connect.
4848
_serverAddressWithPort: string = '';

packages/metro-inspector-proxy/src/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ yargs.option('port', {
1818
alias: 'p',
1919
describe: 'port to run inspector proxy on',
2020
type: 'number',
21-
default: 8082,
21+
default: 8081,
2222
});
2323

2424
runInspectorProxy((yargs.argv.port: any));

packages/metro/src/index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const outputBundle = require('./shared/output/bundle');
2424

2525
const {readFile} = require('fs-extra');
2626
const {loadConfig, mergeConfig, getDefaultConfig} = require('metro-config');
27-
const {runInspectorProxy} = require('metro-inspector-proxy');
27+
const {InspectorProxy} = require('metro-inspector-proxy');
2828

2929
import type {Graph} from './DeltaBundler';
3030
import type {CustomTransformOptions} from './JSTransformer/worker';
@@ -154,13 +154,9 @@ exports.runServer = async (
154154
}
155155
}
156156

157+
let inspectorProxy: ?InspectorProxy = null;
157158
if (config.server.runInspectorProxy) {
158-
// Port number is hardcoded here now for a transition state.
159-
// When Inspector Proxy will be ready to use we will change
160-
// this to use the same port as Metro (this will require
161-
// creating new InspectorProxy and attaching it to httpServer
162-
// instead of creating new HTTP Server).
163-
runInspectorProxy(8082);
159+
inspectorProxy = new InspectorProxy();
164160
}
165161

166162
let httpServer;
@@ -192,6 +188,16 @@ exports.runServer = async (
192188
if (hmrEnabled) {
193189
attachHmrServer(httpServer);
194190
}
191+
192+
if (inspectorProxy) {
193+
inspectorProxy.addWebSocketListener(httpServer);
194+
195+
// TODO(hypuk): Refactor inspectorProxy.processRequest into separate request handlers
196+
// so that we could provide routes (/json/list and /json/version) here.
197+
// Currently this causes Metro to give warning about T31407894.
198+
serverApp.use(inspectorProxy.processRequest.bind(inspectorProxy));
199+
}
200+
195201
resolve(httpServer);
196202
});
197203

0 commit comments

Comments
 (0)