Skip to content

Commit c47f202

Browse files
authored
Fix / revert fetch TypeError handling (#415)
fix(subscribe): fix / revert `fetch` `TypeError` handling 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).
1 parent e95f8a0 commit c47f202

File tree

10 files changed

+25
-22
lines changed

10 files changed

+25
-22
lines changed

.pubnub.yml

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
---
22
changelog:
3+
- date: 2024-10-25
4+
version: v8.2.9
5+
changes:
6+
- type: bug
7+
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)."
38
- date: 2024-09-30
49
version: v8.2.8
510
changes:
@@ -1036,7 +1041,7 @@ supported-platforms:
10361041
- 'Ubuntu 14.04 and up'
10371042
- 'Windows 7 and up'
10381043
version: 'Pubnub Javascript for Node'
1039-
version: '8.2.8'
1044+
version: '8.2.9'
10401045
sdks:
10411046
- full-name: PubNub Javascript SDK
10421047
short-name: Javascript
@@ -1052,7 +1057,7 @@ sdks:
10521057
- distribution-type: source
10531058
distribution-repository: GitHub release
10541059
package-name: pubnub.js
1055-
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.8.zip
1060+
location: https://github.com/pubnub/javascript/archive/refs/tags/v8.2.9.zip
10561061
requires:
10571062
- name: 'agentkeepalive'
10581063
min-version: '3.5.2'
@@ -1723,7 +1728,7 @@ sdks:
17231728
- distribution-type: library
17241729
distribution-repository: GitHub release
17251730
package-name: pubnub.js
1726-
location: https://github.com/pubnub/javascript/releases/download/v8.2.8/pubnub.8.2.8.js
1731+
location: https://github.com/pubnub/javascript/releases/download/v8.2.9/pubnub.8.2.9.js
17271732
requires:
17281733
- name: 'agentkeepalive'
17291734
min-version: '3.5.2'

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v8.2.9
2+
October 25 2024
3+
4+
#### Fixed
5+
- 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).
6+
17
## v8.2.8
28
September 30 2024
39

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ Watch [Getting Started with PubNub JS SDK](https://app.dashcam.io/replay/64ee0d2
2828
npm install pubnub
2929
```
3030
* or download one of our builds from our CDN:
31-
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.8.js
32-
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.8.min.js
31+
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.9.js
32+
* https://cdn.pubnub.com/sdk/javascript/pubnub.8.2.9.min.js
3333
3434
2. Configure your keys:
3535

dist/web/pubnub.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -2839,10 +2839,7 @@
28392839
message = 'Network issues';
28402840
}
28412841
else if (errorName === 'TypeError') {
2842-
if (message.indexOf('Load failed') !== -1 || message.indexOf('Failed to fetch') != -1)
2843-
category = StatusCategory$1.PNTimeoutCategory;
2844-
else
2845-
category = StatusCategory$1.PNBadRequestCategory;
2842+
category = StatusCategory$1.PNBadRequestCategory;
28462843
}
28472844
else if (errorName === 'FetchError') {
28482845
const errorCode = error.code;
@@ -3816,7 +3813,7 @@
38163813
return base.PubNubFile;
38173814
},
38183815
get version() {
3819-
return '8.2.8';
3816+
return '8.2.9';
38203817
},
38213818
getVersion() {
38223819
return this.version;

dist/web/pubnub.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/core/components/configuration.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ const makeConfiguration = (base, setupCryptoModule) => {
110110
return base.PubNubFile;
111111
},
112112
get version() {
113-
return '8.2.8';
113+
return '8.2.9';
114114
},
115115
getVersion() {
116116
return this.version;

lib/errors/pubnub-api-error.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ class PubNubAPIError extends Error {
6262
message = 'Network issues';
6363
}
6464
else if (errorName === 'TypeError') {
65-
if (message.indexOf('Load failed') !== -1 || message.indexOf('Failed to fetch') != -1)
66-
category = categories_1.default.PNTimeoutCategory;
67-
else
68-
category = categories_1.default.PNBadRequestCategory;
65+
category = categories_1.default.PNBadRequestCategory;
6966
}
7067
else if (errorName === 'FetchError') {
7168
const errorCode = error.code;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pubnub",
3-
"version": "8.2.8",
3+
"version": "8.2.9",
44
"author": "PubNub <[email protected]>",
55
"description": "Publish & Subscribe Real-time Messaging with PubNub",
66
"scripts": {

src/core/components/configuration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export const makeConfiguration = (
169169
return base.PubNubFile;
170170
},
171171
get version(): string {
172-
return '8.2.8';
172+
return '8.2.9';
173173
},
174174
getVersion(): string {
175175
return this.version;

src/errors/pubnub-api-error.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ export class PubNubAPIError extends Error {
5858
category = StatusCategory.PNNetworkIssuesCategory;
5959
message = 'Network issues';
6060
} else if (errorName === 'TypeError') {
61-
if (message.indexOf('Load failed') !== -1 || message.indexOf('Failed to fetch') != -1)
62-
category = StatusCategory.PNTimeoutCategory;
63-
else category = StatusCategory.PNBadRequestCategory;
61+
category = StatusCategory.PNBadRequestCategory;
6462
} else if (errorName === 'FetchError') {
6563
const errorCode = (error as Record<string, string>).code;
6664

0 commit comments

Comments
 (0)