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

Expose request ids used by WebSocketProvider #1018

Closed
naddison36 opened this issue Aug 27, 2020 · 3 comments
Closed

Expose request ids used by WebSocketProvider #1018

naddison36 opened this issue Aug 27, 2020 · 3 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@naddison36
Copy link

naddison36 commented Aug 27, 2020

Can the WebSocketProvider class expose the ids of its requests? This is handy for correlating requests with responses in application logs.

Two ways this can be done are:

  1. Move the NextId variable to a readonly property on the WebSocketProvider class

  2. Just use _nextId on the JsonRpcProvider class that WebSocketProvider extends.

Here's an example from my extension of the JsonRpcProvider class

	public async send(method: string, params: any): Promise<any> {
        const requestId = this._nextId
        logger.debug(`About to send JSON-RPC request`, {
            method,
            params,
            id: this._nextId,
        })
        const response = await super.send(method, params)
        logger.debug(`JSON RPC response`, {
            method,
            response,
            id: requestId,
        })
        return response
    }
@ricmoo
Copy link
Member

ricmoo commented Sep 13, 2020

You are correct, I should mimic the JsonRpcProvider.send logic in the WebScoket.send.

I'll add that soon. :)

@ricmoo ricmoo added enhancement New feature or improvement. on-deck This Enhancement or Bug is currently being worked on. labels Sep 13, 2020
@ricmoo
Copy link
Member

ricmoo commented Oct 8, 2020

This has been added in 5.0.17. Try it out and let me know how it works for you. :)

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed on-deck This Enhancement or Bug is currently being worked on. labels Oct 8, 2020
@ricmoo
Copy link
Member

ricmoo commented Oct 23, 2020

Closing this now. If you have any issues with it, please feel free to re-open.

Thanks! :)

@ricmoo ricmoo closed this as completed Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants