Hawkbat / VTubeStudioJS

An implementation of the VTube Studio API for Node and browser JS
MIT License
45 stars 2 forks source link

Are there any way to change timeout interval? #4

Closed satetsu888 closed 2 years ago

satetsu888 commented 2 years ago

First of all, thank you for nice library! I currently create plugin with VTubeStudioJS!

I thought timeout interval in this lib is fixed, and it could occur a little inconvenience. Because of first AuthenticationTokenRequest shows popup in VTubeStudio, user who read popup carefully will not push accept button in 5 sec.

So, I want to set timeout more long only Authentication request. Are there any way to do that?

I've read a code around here https://github.com/Hawkbat/VTubeStudioJS/blob/189f91ff07ca023d97795d01994a75eb7e01d6e4/src/api.ts#L82-L85

Hawkbat commented 2 years ago

That's a great catch, I hadn't considered how the timeout would cause issues for that particular call. I'll push an update out that significantly increases the timeout for the AuthenticationToken endpoint and also allows for configuring of timeouts per call.

Hawkbat commented 2 years ago

I've published a new version to NPM, vtubestudio@1.9.0, that increases the timeout for the AuthenticationTokenRequest to 5 minutes, and allows the timeout for any raw API call to be passed by specifying a second options object to the call, like so:

const stats = await apiClient.statistics({}, { timeout: 60000 });

Let me know if that covers your use case!

satetsu888 commented 2 years ago

Thank you! I got some error during checking new version. please see https://github.com/Hawkbat/VTubeStudioJS/pull/5

As for the timeout issue, it worked fine, including this patch

Hawkbat commented 2 years ago

Fixed in v1.9.1.