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

Every new request opens new connection #570

Open
technic opened this issue Sep 22, 2023 · 5 comments
Open

Every new request opens new connection #570

technic opened this issue Sep 22, 2023 · 5 comments

Comments

@technic
Copy link

technic commented Sep 22, 2023

This is supper inefficient. Please fix. We already have api object in the code with corresponding requests methods, so connection can be stored in the object.

Upd:
With some monkey patching it can be fixed like this:

class ApiFactory {
    rest: rm.RestClient

    constructor(public uri: string, private token: string) {
        this.rest = new rm.RestClient('test', uri, [new BasicCredentialHandler('', this.token)], {keepAlive: true, maxSockets:1 })
    }

    createApi<T extends ClientApiBase>(f: new (string, [IRequestHandler]) => T) {
        const apiClinet = new f(this.uri, [getPersonalAccessTokenHandler(this.token)])
        apiClinet.rest = this.rest
        apiClinet.vsoClient.restClient = this.rest
        return apiClinet
    }
}

This way it works reliable and fast, without hitting azure DevOps rate-limiters due to multiple connections.

Copy link

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label Dec 31, 2023
@technic
Copy link
Author

technic commented Jan 1, 2024

bump

@github-actions github-actions bot removed the stale label Jan 1, 2024
@szwalkowski
Copy link

Bump

Copy link

github-actions bot commented Jun 2, 2024

This issue has had no activity in 90 days. Please comment if it is not actually stale

@github-actions github-actions bot added the stale label Jun 2, 2024
@zkbule
Copy link

zkbule commented Jun 3, 2024

This issue has had no activity in 90 days. Please comment if it is not actually stale

not stale

@github-actions github-actions bot removed the stale label Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants