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

superagent replacement and web worker for web #367

Merged
merged 34 commits into from
Apr 22, 2024

Conversation

parfeon
Copy link
Contributor

@parfeon parfeon commented Mar 29, 2024

feat(network): replace superagent with fetch

Upgraded the network layer, replacing the superagent module with the Fetch API for browser integrations and node-fetch for npm integrations, ensuring enhanced performance and reliability.

feat(service-worker): added service worker

Enhanced the subscribe feature with service worker support, improving user experience across multiple browser windows and tabs.

feat(types): client interface rewritten with TypeScript

The client interface rewritten with TypeScript, which gives an up-to-date interface.

Separate transport provider for browser version of PubNub SDK to provide better user experience.

feat(types): client interface rewritten with TypeScript

Client interface rewritten with TypeScript which gives up-tp-date interface.
refactor(error): update error payload and emit status object types

refactor(build): update target and module to `ES6`
/**
* Whether PubNub client should try utilize existing TCP connection for new requests or not.
*/
const KEEP_ALIVE = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! to keep it true default.
also, assuming that it wont have any side effect.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like true is the default for fetch Web API itself in web environment.

src/web/index.ts Outdated

constructor(configuration: PubNubConfiguration) {
const configurationCopy = setDefaults(configuration);
const platformConfiguration = { ...configurationCopy, sdkFamily: 'Nodejs', PubNubFile };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn’t it be ‘web’ instead of ‘Nodejs’?

sdkFamily: 'Web'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh shoot, probably didn't save when fixed it once. Thank you for noticing!

src/web/index.ts Outdated Show resolved Hide resolved
parfeon and others added 5 commits April 1, 2024 11:28
Co-authored-by: Mohit Tejani <60129002+mohitpubnub@users.noreply.github.com>
…ub/javascript into feature/network-provider-interfaces
Bumped used NodeJS version to start from 18 because lower version EOL'ed.
Fix active request cancellation handling and proper abort handler reset.
Copy link
Contributor

@mohitpubnub mohitpubnub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far Look good!

// type: 'module',
// },
// );
this.worker = new Worker(WEB_WORKER_PLACEHOLDER, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

parfeon added 2 commits April 16, 2024 02:36
test: restore tests

Fix tests runner and updated client inconsistency with previous behavior discovered by failing
tests.
parfeon added 8 commits April 18, 2024 17:06
Fix issue because of which actual leave call not used.

fix(event-engine): proper handling of cancelled requests

Update code to use category instead of `Aborted` error message (which not valid anymore).

test(contract): fix contract tests
Clean up internal Subscription Service Worker state from information about PubNub client which
is not reachable through Service Worker Client (client with linked ID can't be fetched).
Fix issue with code import in `CommonJS` projects.
@@ -2,7 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"module": "CommonJS",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@parfeon
Copy link
Contributor Author

parfeon commented Apr 22, 2024

@pubnub-release-bot release as v8.0.0

@parfeon parfeon merged commit 410930f into master Apr 22, 2024
6 of 7 checks passed
@parfeon parfeon deleted the feature/network-provider-interfaces branch April 22, 2024 19:17
@pubnub-release-bot
Copy link
Contributor

🚀 Release successfully completed 🚀

@k-funk
Copy link

k-funk commented Dec 18, 2024

this change suggests that the minimum browser versions supported may have been bumped to 2017. https://caniuse.com/fetch

Does pubnub document anywhere what these minimums are?

@parfeon
Copy link
Contributor Author

parfeon commented Dec 18, 2024

@k-funk The latest one, Safari, jumped on the train of modern techs, did it seven years ago, while others did it nine years ago. To keep compatibility with the most number of user environments, we deliberately didn't use the most advanced browser features.
We don't have a separate documentation section which specifies the minimum browser version, but because it has been adopted almost a decade ago, we didn't felt that we need to add it. If users were using these outdated browsers or operating systems, they would have issues with modern web applications anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants