Skip to content

Commit 66562b8

Browse files
Merge pull request #2239 from appbaseio/v3-http-request-timeout
web: V3 http request timeout
2 parents 1be717f + f8b9382 commit 66562b8

File tree

7 files changed

+4152
-4097
lines changed

7 files changed

+4152
-4097
lines changed

packages/maps-native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
"react-native": "~0.62.3"
4848
},
4949
"dependencies": {
50-
"@appbaseio/reactivecore": "9.15.0",
50+
"@appbaseio/reactivecore": "9.15.1",
5151
"@ptomasroos/react-native-multi-slider": "^0.0.13",
5252
"appbase-js": "^5.2.0",
5353
"hoist-non-react-statics": "^3.3.0",
5454
"native-base": "^2.4.2",
5555
"prop-types": "^15.6.1"
5656
}
57-
}
57+
}

packages/native/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"react-native": "~0.62.3"
4545
},
4646
"dependencies": {
47-
"@appbaseio/reactivecore": "9.15.0",
47+
"@appbaseio/reactivecore": "9.15.1",
4848
"@babel/polyfill": "^7.0.0-rc.3",
4949
"@ptomasroos/react-native-multi-slider": "^1.0.0",
5050
"appbase-js": "^5.2.0",
@@ -55,4 +55,4 @@
5555
"react-native-calendars": "^1.18.2",
5656
"react-redux": "^5.0.7"
5757
}
58-
}
58+
}

packages/reactivecore

packages/vue/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
"sideEffects": false,
3636
"dependencies": {
3737
"@appbaseio/analytics": "^1.1.1",
38-
"@appbaseio/reactivecore": "9.15.0",
38+
"@appbaseio/reactivecore": "9.15.1",
3939
"@appbaseio/vue-emotion": "0.4.4",
4040
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0",
41-
"appbase-js": "^5.3.3",
41+
"appbase-js": "^5.3.4",
4242
"compute-scroll-into-view": "^1.0.11",
4343
"emotion": "9.2.12",
4444
"gmap-vue": "^3.5.4",

packages/web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
"license": "Apache-2.0",
3939
"dependencies": {
4040
"@appbaseio/analytics": "^1.1.1",
41-
"@appbaseio/reactivecore": "9.15.0",
41+
"@appbaseio/reactivecore": "9.15.1",
4242
"@appbaseio/rheostat": "^1.0.0-alpha.15",
4343
"@emotion/core": "^10.0.28",
4444
"@emotion/styled": "^10.0.27",
45-
"appbase-js": "^5.2.0",
45+
"appbase-js": "^5.3.4",
4646
"cross-env": "^5.2.0",
4747
"dayjs": "^1.11.7",
4848
"downshift": "^1.31.2",

packages/web/src/components/basic/ReactiveBase.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class ReactiveBase extends Component {
7474
],
7575
() => {
7676
this.setStore(this.props);
77-
this.setState(state => ({
77+
this.setState((state) => ({
7878
key: `${state.key}-0`,
7979
}));
8080
},
@@ -104,30 +104,28 @@ class ReactiveBase extends Component {
104104
}
105105

106106
get headers() {
107-
const {
108-
enableAppbase, headers, appbaseConfig, mongodb, endpoint,
109-
} = this.props;
107+
const { enableAppbase, headers, appbaseConfig, mongodb, endpoint } = this.props;
110108
const { enableTelemetry } = appbaseConfig || {};
111109
return {
112-
...(enableAppbase
113-
&& !mongodb && {
114-
'X-Search-Client': X_SEARCH_CLIENT,
115-
...(enableTelemetry === false && { 'X-Enable-Telemetry': false }),
116-
}),
110+
...(enableAppbase &&
111+
!mongodb && {
112+
'X-Search-Client': X_SEARCH_CLIENT,
113+
...(enableTelemetry === false && { 'X-Enable-Telemetry': false }),
114+
}),
117115
...headers,
118-
...(enableAppbase
119-
&& endpoint
120-
&& endpoint.headers && {
121-
...endpoint.headers,
122-
}),
116+
...(enableAppbase &&
117+
endpoint &&
118+
endpoint.headers && {
119+
...endpoint.headers,
120+
}),
123121
};
124122
}
125123

126124
setStore = (props) => {
127125
this.type = props.type ? props.type : '*';
128126

129-
const credentials
130-
= props.url && props.url.trim() !== '' && !props.credentials ? null : props.credentials;
127+
const credentials =
128+
props.url && props.url.trim() !== '' && !props.credentials ? null : props.credentials;
131129

132130
const appbaseConfig = {
133131
...props.analyticsConfig, // TODO: remove in 4.0
@@ -157,8 +155,9 @@ class ReactiveBase extends Component {
157155
graphQLUrl: props.graphQLUrl,
158156
transformResponse: props.transformResponse,
159157
mongodb: props.mongodb,
160-
...(props.enableAppbase
161-
&& props.endpoint instanceof Object && { endpoint: props.endpoint }),
158+
...(props.enableAppbase &&
159+
props.endpoint instanceof Object && { endpoint: props.endpoint }),
160+
httpRequestTimeout: props.httpRequestTimeout * 1000,
162161
};
163162

164163
let queryParams = '';
@@ -220,12 +219,13 @@ class ReactiveBase extends Component {
220219
if (this.props.endpoint && this.props.endpoint.url) {
221220
// Remove parts between '//' and first '/' in the url
222221
analyticsInitConfig.url = this.props.endpoint.url.replace(/\/\/(.*?)\/.*/, '//$1');
223-
const headerCredentials = this.props.endpoint.headers
224-
&& this.props.endpoint.headers.Authorization;
225-
analyticsInitConfig.credentials = headerCredentials && headerCredentials.replace('Basic ', '');
222+
const headerCredentials =
223+
this.props.endpoint.headers && this.props.endpoint.headers.Authorization;
224+
analyticsInitConfig.credentials =
225+
headerCredentials && headerCredentials.replace('Basic ', '');
226226
// Decode the credentials
227-
analyticsInitConfig.credentials = analyticsInitConfig.credentials
228-
&& atob(analyticsInitConfig.credentials);
227+
analyticsInitConfig.credentials =
228+
analyticsInitConfig.credentials && atob(analyticsInitConfig.credentials);
229229
}
230230
} catch (e) {
231231
console.error('Endpoint not set correctly for analytics');
@@ -291,6 +291,7 @@ ReactiveBase.defaultProps = {
291291
as: 'div',
292292
enableAppbase: false,
293293
endpoint: null,
294+
httpRequestTimeout: 30,
294295
};
295296

296297
ReactiveBase.propTypes = {
@@ -322,6 +323,7 @@ ReactiveBase.propTypes = {
322323
mongodb: types.mongodb,
323324
preferences: types.preferences,
324325
endpoint: types.endpoint,
326+
httpRequestTimeout: types.number,
325327
};
326328

327329
export default ReactiveBase;

0 commit comments

Comments
 (0)