Skip to content

Commit

Permalink
default embedder script for open-source (facebook#46302)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#46302

Changelog:
[General][Fixed] - Removed noisy ENOENT error message upon launching the debugger

As described in T200199544, Metro terminal in open-source would show an error message for the missing embedder script.

In this diff, we add a response of an empty file to open-source (no-op)

Reviewed By: hoxyq

Differential Revision: D62103015

fbshipit-source-id: 219bc398b7786527db00528cca175adc13a527a0
  • Loading branch information
EdmondChuiHW authored and facebook-github-bot committed Sep 2, 2024
1 parent 3350050 commit 5bbf5a4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/dev-middleware/src/__tests__/embedderScriptStub-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
* @oncall react_native
*/

import {fetchLocal} from './FetchUtils';
import {withServerForEachTest} from './ServerUtils';

jest.useRealTimers();
jest.setTimeout(10000);

describe('embedder script', () => {
const serverRef = withServerForEachTest({
logger: undefined,
projectRoot: '',
});

test('is always served', async () => {
const resp = await fetchLocal(
serverRef.serverBaseUrl +
'/debugger-frontend/embedder-static/embedderScript.js',
);
expect(resp.ok).toBeTruthy();
expect(resp.status).toBe(200);
});
});
7 changes: 7 additions & 0 deletions packages/dev-middleware/src/createDevMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ export default function createDevMiddleware({
logger,
}),
)
.use(
'/debugger-frontend/embedder-static/embedderScript.js',
(_req, res) => {
res.setHeader('Content-Type', 'application/javascript');
res.end('');
},
)
.use(
'/debugger-frontend',
serveStaticMiddleware(path.join(reactNativeDebuggerFrontendPath), {
Expand Down

0 comments on commit 5bbf5a4

Please sign in to comment.