-
Notifications
You must be signed in to change notification settings - Fork 401
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
Add the ability to switch transport API #435
Conversation
For the browser version of PubNub SDK, add the ability to switch between `fetch` and `xhr` APIs (`transport` configuration option). fix(event-engine): handshake/receive requests timeout Fix issue because of which, in Event Engine mode, wrong timeout values have been set for requests which create long-poll request. refactor(request): make sure request cancels on timeout Refactor `timeout` implementation for `fetch` transport to properly cancel request when the timeout timer will fire.
@@ -118,6 +132,7 @@ export const setDefaults = (configuration: PubNubConfiguration): PubNubConfigura | |||
listenToBrowserNetworkEvents: configuration.listenToBrowserNetworkEvents ?? LISTEN_TO_BROWSER_NETWORK_EVENTS, | |||
subscriptionWorkerUrl: configuration.subscriptionWorkerUrl, | |||
subscriptionWorkerLogVerbosity: configuration.subscriptionWorkerLogVerbosity ?? SUBSCRIPTION_WORKER_LOG_VERBOSITY, | |||
transport: configuration.transport ?? TRANSPORT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
* | ||
* @default `fetch` | ||
*/ | ||
transport?: 'fetch' | 'xhr'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
*/ | ||
private async sendXHRRequest(req: WebTransportRequest, controller: WebCancellationController): Promise<Response> { | ||
return new Promise<Response>((resolve, reject) => { | ||
const xhr = new XMLHttpRequest(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we go again!!!! :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a backup for really messed up case with APM tools and some weird browser restrictions which maybe enforced... fetch
is shiny and better :)
@pubnub-release-bot release |
🚀 Release successfully completed 🚀 |
feat(transport): add the ability to switch transport API
For the browser version of PubNub SDK, add the ability to switch between
fetch
andxhr
APIs (transport
configuration option).fix(event-engine): handshake/receive requests timeout
Fix issue because of which, in Event Engine mode, wrong timeout values have been set for requests which create long-poll request.
refactor(request): make sure request cancels on timeout
Refactor
timeout
implementation forfetch
transport to properly cancel request when the timeout timer will fire.