httptoolkit / httptoolkit-ui

The UI of HTTP Toolkit
https://httptoolkit.com
GNU Affero General Public License v3.0
288 stars 107 forks source link

fix: edge case - empty exchanges #53

Closed roschaefer closed 2 years ago

roschaefer commented 2 years ago

I don't even know if it may happen in the normal use-case scenario that exchanges are empty. In this case, sourceStartTime will be empty and dateFns.format will complain.

I would love to write a unit-test for this, but running npm run test gives the following output:

$ echo $CHROME_BIN
/usr/bin/chromedriver

$ npm run test:unit

> httptoolkit-ui@0.1.0 test:unit
> env-cmd -f ./automation/ts-node.env karma start ./test/unit/karma.conf.js

START:
ℹ 「wdm」: Compiled successfully.
ℹ 「wdm」: Compiling...
ℹ 「wdm」: Compiled successfully.
29 08 2022 13:48:57.863:INFO [karma-server]: Karma v3.1.4 server started at http://0.0.0.0:9876/
29 08 2022 13:48:57.864:INFO [launcher]: Launching browsers ChromeHeadlessNoSandbox with concurrency unlimited
29 08 2022 13:48:57.866:INFO [launcher]: Starting browser ChromeHeadless
29 08 2022 13:49:57.912:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
29 08 2022 13:49:57.916:INFO [launcher]: Trying to start ChromeHeadless again (1/2).
29 08 2022 13:50:57.975:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
29 08 2022 13:50:57.979:INFO [launcher]: Trying to start ChromeHeadless again (2/2).
29 08 2022 13:51:57.995:WARN [launcher]: ChromeHeadless have not captured in 60000 ms, killing.
29 08 2022 13:51:57.999:ERROR [launcher]: ChromeHeadless failed 2 times (timeout). Giving up.

For context: This is the only tiny fix from my attempt to use mockttp as a forward proxy to intercept network traffic. I used the code in this file to export a .har file.

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

roschaefer commented 2 years ago

Sad that I cannot trigger the test pipeline with this PR.

pimterry commented 2 years ago

Thanks @roschaefer, this looks great! Not sure what's going on with the local testing for you there, for whatever reason Karma can't seem to start Chrome on your machine. Not a big deal though, everything passes in CI and I'm happy to merge this as-is.

Sad that I cannot trigger the test pipeline with this PR.

Sorry, this is just standard GitHub open-source configuration - nowadays CI jobs never run automatically for PRs from new contributors.