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

[expo-dev-launcher] Add missing Network.requestWillBeSentExtraInfo event #21965

Merged
merged 6 commits into from
Apr 4, 2023

Conversation

byCedric
Copy link
Member

@byCedric byCedric commented Apr 3, 2023

Why

This fixes the last two remaining "weird debug information" in chrome devtools.

  1. The request headers are marked as "⚠️ Provisional headers shown"
  2. The Timing column is stuck on "Pending" instead of showing the actual request time.
Page Screenshot
Overview
Headers tab
Timing tab image

How

The two missing pieces of information are sent in the Network.requestWillBeSentExtraInfo event, under headers and connectTiming.requestTime.

I don't think we can actually get the connectionStart/connectionEnd timing, as described here. Instead of fetching that value, we just skip it and let chrome devtools only show the actual response time.

Test Plan

  • Make a request fetch('https://httpbin.org/anything')
  • Check the network tab
  • Should NOT show ⚠️ Provisional headers are shown
  • Should NOT show Pending under Timing

Checklist

@byCedric byCedric requested a review from Kudo April 3, 2023 16:50
@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label Apr 3, 2023
@@ -80,11 +80,25 @@ class DevLauncherNetworkLogger private constructor() {
))
}
}
val data = JSONObject(mapOf(
var data = JSONObject(mapOf(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like changing from val to var if not needed. Just create a new variable with a meaningful name instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, do you want me to change the others as well? I copied this from:

params = mapOf(
"requestId" to requestId,
"timestamp" to now,
"encodedDataLength" to (response.body()?.contentLength() ?: 0),
)
data = JSONObject(mapOf(

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it's a good idea. Thanks

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Apr 3, 2023
}

/**
* Emits CDP `Network.responseReceived` and `Network.loadingFinished` events
*/
fun emitNetworkResponse(request: Request, requestId: String, response: Response) {
val now = BigDecimal(System.currentTimeMillis() / 1000.0).setScale(3, RoundingMode.CEILING)
var params = mapOf(
val responseReceivedParams = mapOf(
"requestId" to requestId,
"loaderId" to "",
"hasExtraInfo" to false,
Copy link
Contributor

Choose a reason for hiding this comment

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

do you think we should set the hasExtraInfo as true when we send the Network.requestWillBeSentExtraInfo?

and also redirectHasExtraInfo maybe

Copy link
Member Author

@byCedric byCedric Apr 3, 2023

Choose a reason for hiding this comment

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

I think you are right about the redirectHasExtraInfo:

image

But I don't think we have to enable the hasExtraInfo on Network.responseReceived, because that refers to the Network.responseReceivedExtraInfo.

So far, this change is only required because of the visual "⚠️ Provisional headers are shown" issue. Which seems to be an oversight in the spec itself, there is no option to say "we are not implementing the Network.requestWillBeSentExtraInfo event". Luckily, we do have an option to disable it for responses (this hasExtraInfo).

Copy link
Contributor

Choose a reason for hiding this comment

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

makes sense and nice explanation! thanks

@byCedric byCedric force-pushed the @bycedric/inspector/add-extra-request-info branch from fc4e209 to 4e7fa54 Compare April 3, 2023 21:31
@byCedric byCedric force-pushed the @bycedric/inspector/add-extra-request-info branch from 4e7fa54 to fc4597b Compare April 4, 2023 11:20
@byCedric byCedric merged commit 0cf2d5a into main Apr 4, 2023
@byCedric byCedric deleted the @bycedric/inspector/add-extra-request-info branch April 4, 2023 12:43
EvanBacon pushed a commit that referenced this pull request Apr 5, 2023
…event (#21965)

# Why

This fixes the last two remaining "weird debug information" in chrome
devtools.

1. The request headers are marked as "⚠️ Provisional headers shown"
2. The `Timing` column is stuck on "Pending" instead of showing the
actual request time.

Page | Screenshot
--- | ---
Overview | <img
src="https://user-images.githubusercontent.com/1203991/229575879-201d2b47-ff02-4512-adc3-72716fad71f8.png">
Headers tab | <img
src="https://user-images.githubusercontent.com/1203991/229575999-b57c6428-a754-4e69-910e-a1cd76c9b761.png">
Timing tab | <img width="1030" alt="image"
src="https://user-images.githubusercontent.com/1203991/229576107-d08d1f65-9203-4e7e-bf4d-73b42bbbbc8f.png">

# How

The two missing pieces of information are sent in the
[`Network.requestWillBeSentExtraInfo`](https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-requestWillBeSentExtraInfo)
event, under `headers` and `connectTiming.requestTime`.

> I don't think we can actually get the
`connectionStart`/`connectionEnd` timing, [as described
here](https://developer.apple.com/documentation/foundation/nsurlsessiontasktransactionmetrics#3162615).
Instead of fetching that value, we just skip it and let chrome devtools
only show the actual response time.

# Test Plan

- Make a request `fetch('https://httpbin.org/anything')`
- Check the network tab
- Should NOT show `⚠️ Provisional headers are shown`
- Should NOT show `Pending` under `Timing`

# Checklist

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

- [ ] 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 `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Kudo Chien <kudo@expo.dev>
Kudo pushed a commit that referenced this pull request Apr 10, 2023
…event (#21965)

# Why

This fixes the last two remaining "weird debug information" in chrome
devtools.

1. The request headers are marked as "⚠️ Provisional headers shown"
2. The `Timing` column is stuck on "Pending" instead of showing the
actual request time.

Page | Screenshot
--- | ---
Overview | <img
src="https://user-images.githubusercontent.com/1203991/229575879-201d2b47-ff02-4512-adc3-72716fad71f8.png">
Headers tab | <img
src="https://user-images.githubusercontent.com/1203991/229575999-b57c6428-a754-4e69-910e-a1cd76c9b761.png">
Timing tab | <img width="1030" alt="image"
src="https://user-images.githubusercontent.com/1203991/229576107-d08d1f65-9203-4e7e-bf4d-73b42bbbbc8f.png">

# How

The two missing pieces of information are sent in the
[`Network.requestWillBeSentExtraInfo`](https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-requestWillBeSentExtraInfo)
event, under `headers` and `connectTiming.requestTime`.

> I don't think we can actually get the
`connectionStart`/`connectionEnd` timing, [as described
here](https://developer.apple.com/documentation/foundation/nsurlsessiontasktransactionmetrics#3162615).
Instead of fetching that value, we just skip it and let chrome devtools
only show the actual response time.

# Test Plan

- Make a request `fetch('https://httpbin.org/anything')`
- Check the network tab
- Should NOT show `⚠️ Provisional headers are shown`
- Should NOT show `Pending` under `Timing`

# Checklist

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

- [ ] 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 `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Kudo Chien <kudo@expo.dev>
(cherry picked from commit 0cf2d5a)
Kudo pushed a commit that referenced this pull request Apr 10, 2023
…event (#21965)

# Why

This fixes the last two remaining "weird debug information" in chrome
devtools.

1. The request headers are marked as "⚠️ Provisional headers shown"
2. The `Timing` column is stuck on "Pending" instead of showing the
actual request time.

Page | Screenshot
--- | ---
Overview | <img
src="https://user-images.githubusercontent.com/1203991/229575879-201d2b47-ff02-4512-adc3-72716fad71f8.png">
Headers tab | <img
src="https://user-images.githubusercontent.com/1203991/229575999-b57c6428-a754-4e69-910e-a1cd76c9b761.png">
Timing tab | <img width="1030" alt="image"
src="https://user-images.githubusercontent.com/1203991/229576107-d08d1f65-9203-4e7e-bf4d-73b42bbbbc8f.png">

# How

The two missing pieces of information are sent in the
[`Network.requestWillBeSentExtraInfo`](https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-requestWillBeSentExtraInfo)
event, under `headers` and `connectTiming.requestTime`.

> I don't think we can actually get the
`connectionStart`/`connectionEnd` timing, [as described
here](https://developer.apple.com/documentation/foundation/nsurlsessiontasktransactionmetrics#3162615).
Instead of fetching that value, we just skip it and let chrome devtools
only show the actual response time.

# Test Plan

- Make a request `fetch('https://httpbin.org/anything')`
- Check the network tab
- Should NOT show `⚠️ Provisional headers are shown`
- Should NOT show `Pending` under `Timing`

# Checklist

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

- [ ] 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 `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Kudo Chien <kudo@expo.dev>
(cherry picked from commit 0cf2d5a)
Kudo pushed a commit that referenced this pull request Apr 10, 2023
…event (#21965)

# Why

This fixes the last two remaining "weird debug information" in chrome
devtools.

1. The request headers are marked as "⚠️ Provisional headers shown"
2. The `Timing` column is stuck on "Pending" instead of showing the
actual request time.

Page | Screenshot
--- | ---
Overview | <img
src="https://user-images.githubusercontent.com/1203991/229575879-201d2b47-ff02-4512-adc3-72716fad71f8.png">
Headers tab | <img
src="https://user-images.githubusercontent.com/1203991/229575999-b57c6428-a754-4e69-910e-a1cd76c9b761.png">
Timing tab | <img width="1030" alt="image"
src="https://user-images.githubusercontent.com/1203991/229576107-d08d1f65-9203-4e7e-bf4d-73b42bbbbc8f.png">

# How

The two missing pieces of information are sent in the
[`Network.requestWillBeSentExtraInfo`](https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-requestWillBeSentExtraInfo)
event, under `headers` and `connectTiming.requestTime`.

> I don't think we can actually get the
`connectionStart`/`connectionEnd` timing, [as described
here](https://developer.apple.com/documentation/foundation/nsurlsessiontasktransactionmetrics#3162615).
Instead of fetching that value, we just skip it and let chrome devtools
only show the actual response time.

# Test Plan

- Make a request `fetch('https://httpbin.org/anything')`
- Check the network tab
- Should NOT show `⚠️ Provisional headers are shown`
- Should NOT show `Pending` under `Timing`

# Checklist

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

- [ ] 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 `expo prebuild` & EAS Build (eg:
updated a module plugin).

---------

Co-authored-by: Kudo Chien <kudo@expo.dev>
(cherry picked from commit 0cf2d5a)
@Kudo Kudo added the published Changes from the PR have been published to npm label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about published Changes from the PR have been published to npm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants