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

Treat response.text() as a promise in error handling. #11

Merged

Conversation

markdoliner-doma
Copy link

@markdoliner-doma markdoliner-doma commented Jul 5, 2022

We recently added some better exception handling but unfortunately printing the response body isn't working because response.text() is a Promise. The message looks like this: ThriftRequestError: Thrift request failed: HTTP 503 Service Unavailable: [object Promise]

The fix is to use .then() to get the body.

I have not tested this. I did run npm run test and some of the tests pass, but 75 out of 108 thrift-integration tests fail. I'm seeing this error a lot:

request to http://localhost:8090/thrift failed, reason: connect ECONNREFUSED ::1:8090

I think it also might have been happening before this change. It looks unrelated. It seems like it's happening because Hapi listens on 127.0.0.1 and Node v17 and higher stopped forcing IPv64addresses to be listed first when resolving domains so now IPv6 addresses can be returned first. I'll probably post a separate PR for that, but for now I'd prefer not to block this change.

We [recently added some better exception handling](#9) but unfortunately printing the response body didn't work because [`response.text()` is a Promise](https://github.github.io/fetch/#response-body). The message looks like this: `ThriftRequestError: Thrift request failed: HTTP 503 Service Unavailable: [object Promise]`

The fix is to use `.then()` to get the body.
@markdoliner-doma markdoliner-doma merged commit b4a4751 into main Jul 6, 2022
@markdoliner-doma markdoliner-doma deleted the markdoliner-doma/Treat_response.text_as_a_promise branch July 6, 2022 13:51
@markdoliner-doma
Copy link
Author

I did run npm run test and some of the tests pass, but 75 out of 108 thrift-integration tests fail. I'm seeing this error a lot:

request to http://localhost:8090/thrift failed, reason: connect ECONNREFUSED ::1:8090

I think it also might have been happening before this change. It looks unrelated. It seems like it's happening because Hapi listens on 127.0.0.1 and Node v17 and higher stopped forcing IPv64addresses to be listed first when resolving domains so now IPv6 addresses can be returned first. I'll probably post a separate PR for that, but for now I'd prefer not to block this change.

I fixed the tests in #12 and #13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants