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

Fix / revert fetch TypeError handling #415

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
---
changelog:
- date: 2024-10-25
version: v8.2.9
changes:
- type: bug
text: "Revert fix created to handle browser timeouts (not gracefully). The Web Fetch API doesn't have descriptive error information, and it sends `TypeError` for both cases when connection closed by browser or network issue (blocked domain)."
- date: 2024-09-30
version: v8.2.8
changes:
Expand Down Expand Up @@ -1036,7 +1041,7 @@ supported-platforms:
- 'Ubuntu 14.04 and up'
- 'Windows 7 and up'
version: 'Pubnub Javascript for Node'
version: '8.2.8'
version: '8.2.9'
sdks:
- full-name: PubNub Javascript SDK
short-name: Javascript
Expand All @@ -1052,7 +1057,7 @@ sdks:
- distribution-type: source
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.8.zip
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.9.zip
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down Expand Up @@ -1723,7 +1728,7 @@ sdks:
- distribution-type: library
distribution-repository: GitHub release
package-name: pubnub.js
location: https://github.com/pubnub/javascript/releases/download/v8.2.8/pubnub.8.2.8.js
location: https://github.com/pubnub/javascript/releases/download/v8.2.9/pubnub.8.2.9.js
requires:
- name: 'agentkeepalive'
min-version: '3.5.2'
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v8.2.9
October 25 2024

#### Fixed
- Revert fix created to handle browser timeouts (not gracefully). The Web Fetch API doesn't have descriptive error information, and it sends `TypeError` for both cases when connection closed by browser or network issue (blocked domain).

## v8.2.8
September 30 2024

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
npm install pubnub
```
* or download one of our builds from our CDN:
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.8.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.8.min.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.9.js
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.9.min.js
2. Configure your keys:
Expand Down
7 changes: 2 additions & 5 deletions dist/web/pubnub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2839,10 +2839,7 @@
message = 'Network issues';
}
else if (errorName === 'TypeError') {
if (message.indexOf('Load failed') !== -1 || message.indexOf('Failed to fetch') != -1)
category = StatusCategory$1.PNTimeoutCategory;
else
category = StatusCategory$1.PNBadRequestCategory;
category = StatusCategory$1.PNBadRequestCategory;
}
else if (errorName === 'FetchError') {
const errorCode = error.code;
Expand Down Expand Up @@ -3816,7 +3813,7 @@
return base.PubNubFile;
},
get version() {
return '8.2.8';
return '8.2.9';
},
getVersion() {
return this.version;
Expand Down
4 changes: 2 additions & 2 deletions dist/web/pubnub.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/core/components/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
return base.PubNubFile;
},
get version() {
return '8.2.8';
return '8.2.9';
},
getVersion() {
return this.version;
Expand Down
5 changes: 1 addition & 4 deletions lib/errors/pubnub-api-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ class PubNubAPIError extends Error {
message = 'Network issues';
}
else if (errorName === 'TypeError') {
if (message.indexOf('Load failed') !== -1 || message.indexOf('Failed to fetch') != -1)
category = categories_1.default.PNTimeoutCategory;
else
category = categories_1.default.PNBadRequestCategory;
category = categories_1.default.PNBadRequestCategory;
}
else if (errorName === 'FetchError') {
const errorCode = error.code;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pubnub",
"version": "8.2.8",
"version": "8.2.9",
"author": "PubNub <[email protected]>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const makeConfiguration = (
return base.PubNubFile;
},
get version(): string {
return '8.2.8';
return '8.2.9';
},
getVersion(): string {
return this.version;
Expand Down
4 changes: 1 addition & 3 deletions src/errors/pubnub-api-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export class PubNubAPIError extends Error {
category = StatusCategory.PNNetworkIssuesCategory;
message = 'Network issues';
} else if (errorName === 'TypeError') {
if (message.indexOf('Load failed') !== -1 || message.indexOf('Failed to fetch') != -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM! for this issue

category = StatusCategory.PNTimeoutCategory;
else category = StatusCategory.PNBadRequestCategory;
category = StatusCategory.PNBadRequestCategory;
} else if (errorName === 'FetchError') {
const errorCode = (error as Record<string, string>).code;

Expand Down
Loading