Socket
Socket
Sign inDemoInstall

@react-native-community/netinfo

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-native-community/netinfo - npm Package Compare versions

Comparing version 9.5.0 to 10.0.0

11

CHANGELOG.md

@@ -0,1 +1,12 @@

# [10.0.0](https://github.com/react-native-netinfo/react-native-netinfo/compare/v9.5.0...v10.0.0) (2023-11-01)
* fix(cancel)!: cancel _checkInternetReachability request on timeout & cancel via AbortController (#678) ([4bfd3e2](https://github.com/react-native-netinfo/react-native-netinfo/commit/4bfd3e2)), closes [#678](https://github.com/react-native-netinfo/react-native-netinfo/issues/678) [/github.com/react-native-netinfo/react-native-netinfo/issues/439#issue-787487438](https://github.com//github.com/react-native-netinfo/react-native-netinfo/issues/439/issues/issue-787487438)
### BREAKING CHANGES
* netinfo now requires AbortController, node v16 / edge required
it will likely not work on internet explorer from this version onwards
# [9.5.0](https://github.com/react-native-netinfo/react-native-netinfo/compare/v9.4.2...v9.5.0) (2023-11-01)

@@ -2,0 +13,0 @@

14

lib/commonjs/internal/internetReachability.js

@@ -70,6 +70,8 @@ "use strict";

_defineProperty(this, "_checkInternetReachability", () => {
const controller = new AbortController();
const responsePromise = fetch(this._configuration.reachabilityUrl, {
headers: this._configuration.reachabilityHeaders,
method: this._configuration.reachabilityMethod,
cache: 'no-cache'
cache: 'no-cache',
signal: controller.signal
}); // Create promise that will reject after the request timeout has been reached

@@ -79,3 +81,6 @@

const timeoutPromise = new Promise((_, reject) => {
timeoutHandle = setTimeout(() => reject('timedout'), this._configuration.reachabilityRequestTimeout);
timeoutHandle = setTimeout(() => {
controller.abort();
reject('timedout');
}, this._configuration.reachabilityRequestTimeout);
}); // Create promise that makes it possible to cancel a pending request through a reject

@@ -87,3 +92,6 @@ // eslint-disable-next-line @typescript-eslint/no-empty-function

const cancelPromise = new Promise((_, reject) => {
cancel = () => reject('canceled');
cancel = () => {
controller.abort();
reject('canceled');
};
});

@@ -90,0 +98,0 @@ const promise = Promise.race([responsePromise, timeoutPromise, cancelPromise]).then(response => {

@@ -63,6 +63,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

_defineProperty(this, "_checkInternetReachability", () => {
const controller = new AbortController();
const responsePromise = fetch(this._configuration.reachabilityUrl, {
headers: this._configuration.reachabilityHeaders,
method: this._configuration.reachabilityMethod,
cache: 'no-cache'
cache: 'no-cache',
signal: controller.signal
}); // Create promise that will reject after the request timeout has been reached

@@ -72,3 +74,6 @@

const timeoutPromise = new Promise((_, reject) => {
timeoutHandle = setTimeout(() => reject('timedout'), this._configuration.reachabilityRequestTimeout);
timeoutHandle = setTimeout(() => {
controller.abort();
reject('timedout');
}, this._configuration.reachabilityRequestTimeout);
}); // Create promise that makes it possible to cancel a pending request through a reject

@@ -80,3 +85,6 @@ // eslint-disable-next-line @typescript-eslint/no-empty-function

const cancelPromise = new Promise((_, reject) => {
cancel = () => reject('canceled');
cancel = () => {
controller.abort();
reject('canceled');
};
});

@@ -83,0 +91,0 @@ const promise = Promise.race([responsePromise, timeoutPromise, cancelPromise]).then(response => {

{
"name": "@react-native-community/netinfo",
"version": "9.5.0",
"version": "10.0.0",
"description": "React Native Network Info API for iOS & Android",

@@ -5,0 +5,0 @@ "react-native": "src/index.ts",

@@ -83,2 +83,8 @@

AbortController is used to cancel network requests, and may not be available on Internet Explorer, though it is available on Edge https://caniuse.com/abortcontroller
## Node Compatibility
Node v16 is the minimum required node version - `AbortController` is only present in stable versions of node from v16 on
## Migrating from the core `react-native` module

@@ -85,0 +91,0 @@ This module was created when the NetInfo was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change you imports from:

@@ -71,2 +71,4 @@ /**

private _checkInternetReachability = (): InternetReachabilityCheckHandler => {
const controller = new AbortController();
const responsePromise = fetch(this._configuration.reachabilityUrl, {

@@ -76,2 +78,3 @@ headers: this._configuration.reachabilityHeaders,

cache: 'no-cache',
signal: controller.signal,
});

@@ -83,6 +86,6 @@

(_, reject): void => {
timeoutHandle = setTimeout(
(): void => reject('timedout'),
this._configuration.reachabilityRequestTimeout,
);
timeoutHandle = setTimeout((): void => {
controller.abort();
reject('timedout');
}, this._configuration.reachabilityRequestTimeout);
},

@@ -96,3 +99,6 @@ );

(_, reject): void => {
cancel = (): void => reject('canceled');
cancel = (): void => {
controller.abort();
reject('canceled');
};
},

@@ -99,0 +105,0 @@ );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc