feat: Errors from gax layer#1090
Merged
danieljbruce merged 23 commits intogoogleapis:mainfrom Jul 4, 2022
Merged
Conversation
danieljbruce
commented
May 24, 2022
| // netServer.listen(port); | ||
| netServer.listen(`localhost:${port}`); | ||
| } | ||
| describe('Ensure server shuts down properly when destroyed', () => { |
Contributor
Author
There was a problem hiding this comment.
If I add a before hook with the following in it:
checkPort(inputPort, false, done);
the assert.notEqual(err.code, 'EADDRINUSE'); fails, but I am not sure why at this time.
Contributor
Author
There was a problem hiding this comment.
I changed the way this worked entirely to use a third party dev dependency.
…into errors-from-gax-layer # Conflicts: # package.json
bcoe
suggested changes
Jun 17, 2022
bcoe
left a comment
There was a problem hiding this comment.
Left a nit, I would always opt for an async/await appraoch, rather than Promise.then these days.
test/util/mock-server.ts
Outdated
| const inputPort = '1234'; | ||
| let server: MockServer; | ||
| function checkPort(port: string, inUse: boolean, callback: () => void) { | ||
| tcpPortUsed.check(parseInt(port), 'localhost').then((isInUse: boolean) => { |
There was a problem hiding this comment.
my advice would be to always use an async/await interface when possible, I think you could replace this with:
await checkPort()
Contributor
Author
There was a problem hiding this comment.
It actually looks like this now:
async function checkPort(port: string, inUse: boolean, callback: () => void) {
const isInUse: boolean = await tcpPortUsed.check(
parseInt(port),
'localhost'
);
assert.strictEqual(isInUse, inUse);
callback();
}
bcoe
approved these changes
Jul 4, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains tests for ensuring that errors which pass through the gax layer are presented to the user properly using unit tests from a grpc service.