Skip to content

fix(dev-middleware): respond with status code 200 when launching RNDT#46814

Closed
byCedric wants to merge 5 commits into
facebook:mainfrom
byCedric:@bycedric/dev-middleware/respond-when-launching-rndt
Closed

fix(dev-middleware): respond with status code 200 when launching RNDT#46814
byCedric wants to merge 5 commits into
facebook:mainfrom
byCedric:@bycedric/dev-middleware/respond-when-launching-rndt

Conversation

@byCedric
Copy link
Copy Markdown
Contributor

@byCedric byCedric commented Oct 3, 2024

Summary:

This fixes an issue where POST /open-debugger?appId&device&target does not return a proper status code, meaning that the request will never be answered and clients might hang until the request timeout is hit.

Changelog:

[GENERAL] [FIXED] - Respond with status code 200 when successfully launching RNDT

Test Plan:

  • curl -v -X POST "<deviceUrl>"
  • This should show a proper response for the request.
before after
image image

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner labels Oct 3, 2024
@byCedric byCedric changed the title @bycedric/dev middleware/respond when launching rndt fix(dev-middleware): respond with status code 200 when launching RNDT Oct 3, 2024
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 3, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

*/
export async function fetchLocal(
url: string,
options?: Parameters<typeof fetch>[1] & {dispatcher?: mixed},
Copy link
Copy Markdown
Contributor Author

@byCedric byCedric Oct 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to add options?: Partial<...>, without this it required me to add all request options as second parameter, while I just want to do:

const response = await fetchLocal('..', {method: 'POST'})

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@huntie has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Oct 4, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@huntie merged this pull request in eeb6122.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by @byCedric in eeb6122

When will my fix make it into a release? | How to file a pick request?

@byCedric byCedric deleted the @bycedric/dev-middleware/respond-when-launching-rndt branch October 4, 2024 10:20
blakef pushed a commit that referenced this pull request Oct 7, 2024
…DT (#46814)

Summary:
This fixes an issue where `POST /open-debugger?appId&device&target` does not return a proper status code, meaning that the request will never be answered and clients might hang until the request timeout is hit.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[GENERAL] [FIXED] - Respond with status code `200` when successfully launching RNDT

Pull Request resolved: #46814

Test Plan:
- `curl -v -X POST "<deviceUrl>"`
- This should show a proper response for the request.

before | after
 --- | ---
![image](https://github.com/user-attachments/assets/5b820acd-1168-4642-90ec-f2eeec0afc16) | ![image](https://github.com/user-attachments/assets/82bb2a6c-3c7b-483f-a4a1-ad00e5ca0178)

Reviewed By: NickGerleman

Differential Revision: D63837025

Pulled By: huntie

fbshipit-source-id: ac72fc793e015f0eec498f4a35b4fb9e301c5b32
byCedric added a commit to expo/expo that referenced this pull request Oct 29, 2024
…quests (#32451)

# Why

Fixes ENG-13977

Originally, there was an issue where the middleware responding to the
"open React Native DevTools" requests never responded with a proper
response. This would cause the terminal become unresponsive as it waited
for the response, or the default timeout was hit.

We've fixed this in facebook/react-native#46814

Unfortunately, that same middleware has another issue. The
[`browserLauncher.launchDebuggerAppWindow`](https://github.com/facebook/react-native/blob/7090b790c6febed048203ea5f5a4f7116d1206cf/packages/dev-middleware/src/middleware/openDebuggerMiddleware.js#L133-L140)
async method never completes. Meaning, we still have that endpoint not
responding to the request properly.

# How

- Added a timeout of 1s to the open debugger request

# Test Plan

- `bun create expo ./test-rndt --template default@next`
- `cd ./test-rndt`
- `bun expo start --ios`
- Press `j` in terminal once the app is started
- Terminal should become responsive again after maximum of 1s

Also added debug logging to check if users run into this timeout state.
You can see this logging with:

- `DEBUG="expo:start:server:middleware:inspector:jsInspector" bun expo
start`

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [x] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).

---------

Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@blakef blakef mentioned this pull request Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants