@appium/base-driver 9.3.18 → 9.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../../lib/express/idempotency.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"idempotency.d.ts","sourceRoot":"","sources":["../../../lib/express/idempotency.js"],"names":[],"mappings":"AA0HA;;;GAGG;AACH,uCAHW,OAAO,SAAS,EAAE,OAAO,OACzB,OAAO,SAAS,EAAE,QAAQ,2BAkDpC"}
|
|
@@ -13,12 +13,13 @@ const IDEMPOTENT_RESPONSES = new lru_cache_1.default({
|
|
|
13
13
|
ttl: 30 * 60 * 1000,
|
|
14
14
|
updateAgeOnGet: true,
|
|
15
15
|
updateAgeOnHas: true,
|
|
16
|
-
dispose: (
|
|
16
|
+
dispose: ({ responseStateListener }) => {
|
|
17
17
|
responseStateListener?.removeAllListeners();
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
const MONITORED_METHODS = ['POST', 'PATCH'];
|
|
21
21
|
const IDEMPOTENCY_KEY_HEADER = 'x-idempotency-key';
|
|
22
|
+
const MAX_CACHED_PAYLOAD_SIZE_BYTES = 1 * 1024 * 1024; // 1 MiB
|
|
22
23
|
/**
|
|
23
24
|
*
|
|
24
25
|
* @param {string} key
|
|
@@ -36,48 +37,80 @@ function cacheResponse(key, req, res) {
|
|
|
36
37
|
response: null,
|
|
37
38
|
responseStateListener,
|
|
38
39
|
});
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const socket = res.socket;
|
|
41
|
+
const originalSocketWriter = socket.write.bind(socket);
|
|
42
|
+
const responseRef = new WeakRef(res);
|
|
43
|
+
let responseChunks = [];
|
|
44
|
+
let responseSize = 0;
|
|
45
|
+
let errorMessage = null;
|
|
41
46
|
const patchedWriter = (chunk, encoding, next) => {
|
|
42
|
-
if (
|
|
43
|
-
|
|
47
|
+
if (errorMessage || !responseRef.deref()) {
|
|
48
|
+
responseChunks = [];
|
|
49
|
+
responseSize = 0;
|
|
50
|
+
return originalSocketWriter(chunk, encoding, next);
|
|
44
51
|
}
|
|
45
|
-
|
|
46
|
-
|
|
52
|
+
const buf = Buffer.from(chunk, encoding);
|
|
53
|
+
responseChunks.push(buf);
|
|
54
|
+
responseSize += buf.length;
|
|
55
|
+
if (responseSize > MAX_CACHED_PAYLOAD_SIZE_BYTES) {
|
|
56
|
+
errorMessage = `The actual response size exceeds ` +
|
|
57
|
+
`the maximum allowed limit of ${MAX_CACHED_PAYLOAD_SIZE_BYTES} bytes`;
|
|
47
58
|
}
|
|
48
59
|
return originalSocketWriter(chunk, encoding, next);
|
|
49
60
|
};
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
res.once('close', () => {
|
|
57
|
-
if (res.socket?.write === patchedWriter) {
|
|
58
|
-
res.socket.write = originalSocketWriter;
|
|
61
|
+
socket.write = patchedWriter;
|
|
62
|
+
let didEmitReady = false;
|
|
63
|
+
res.once('error', (e) => {
|
|
64
|
+
errorMessage = e.message;
|
|
65
|
+
if (socket.write === patchedWriter) {
|
|
66
|
+
socket.write = originalSocketWriter;
|
|
59
67
|
}
|
|
60
68
|
if (!IDEMPOTENT_RESPONSES.has(key)) {
|
|
61
69
|
logger_1.default.info(`Could not cache the response identified by '${key}'. ` +
|
|
62
70
|
`Cache consistency has been damaged`);
|
|
63
71
|
}
|
|
64
|
-
else
|
|
65
|
-
logger_1.default.info(`Could not cache the response identified by '${key}': ${
|
|
72
|
+
else {
|
|
73
|
+
logger_1.default.info(`Could not cache the response identified by '${key}': ${errorMessage}`);
|
|
66
74
|
IDEMPOTENT_RESPONSES.delete(key);
|
|
67
75
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
responseChunks = [];
|
|
77
|
+
responseSize = 0;
|
|
78
|
+
if (!didEmitReady) {
|
|
79
|
+
responseStateListener.emit('ready', null);
|
|
80
|
+
didEmitReady = true;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
res.once('finish', () => {
|
|
84
|
+
if (socket.write === patchedWriter) {
|
|
85
|
+
socket.write = originalSocketWriter;
|
|
86
|
+
}
|
|
87
|
+
if (!IDEMPOTENT_RESPONSES.has(key)) {
|
|
88
|
+
logger_1.default.info(`Could not cache the response identified by '${key}'. ` +
|
|
89
|
+
`Cache consistency has been damaged`);
|
|
90
|
+
}
|
|
91
|
+
else if (errorMessage) {
|
|
92
|
+
logger_1.default.info(`Could not cache the response identified by '${key}': ${errorMessage}`);
|
|
72
93
|
IDEMPOTENT_RESPONSES.delete(key);
|
|
73
94
|
}
|
|
74
95
|
const value = IDEMPOTENT_RESPONSES.get(key);
|
|
75
96
|
if (value) {
|
|
76
|
-
value.response = Buffer.
|
|
77
|
-
responseStateListener.emit('ready', value.response);
|
|
97
|
+
value.response = Buffer.concat(responseChunks);
|
|
78
98
|
}
|
|
79
|
-
|
|
80
|
-
|
|
99
|
+
responseChunks = [];
|
|
100
|
+
responseSize = 0;
|
|
101
|
+
if (!didEmitReady) {
|
|
102
|
+
responseStateListener.emit('ready', value?.response ?? null);
|
|
103
|
+
didEmitReady = true;
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
res.once('close', () => {
|
|
107
|
+
if (socket.write === patchedWriter) {
|
|
108
|
+
socket.write = originalSocketWriter;
|
|
109
|
+
}
|
|
110
|
+
if (!didEmitReady) {
|
|
111
|
+
const value = IDEMPOTENT_RESPONSES.get(key);
|
|
112
|
+
responseStateListener.emit('ready', value?.response ?? null);
|
|
113
|
+
didEmitReady = true;
|
|
81
114
|
}
|
|
82
115
|
});
|
|
83
116
|
}
|
|
@@ -87,7 +120,7 @@ function cacheResponse(key, req, res) {
|
|
|
87
120
|
*/
|
|
88
121
|
async function handleIdempotency(req, res, next) {
|
|
89
122
|
const keyOrArr = req.headers[IDEMPOTENCY_KEY_HEADER];
|
|
90
|
-
if (!keyOrArr) {
|
|
123
|
+
if (lodash_1.default.isEmpty(keyOrArr) || !keyOrArr) {
|
|
91
124
|
return next();
|
|
92
125
|
}
|
|
93
126
|
const key = lodash_1.default.isArray(keyOrArr) ? keyOrArr[0] : keyOrArr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../../../lib/express/idempotency.js"],"names":[],"mappings":";;;;;;AAAA,sDAA2B;AAC3B,0DAA4B;AAC5B,oDAAuB;AACvB,mCAAoC;AAEpC,MAAM,oBAAoB,GAAG,IAAI,mBAAG,CAAC;IACnC,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"idempotency.js","sourceRoot":"","sources":["../../../lib/express/idempotency.js"],"names":[],"mappings":";;;;;;AAAA,sDAA2B;AAC3B,0DAA4B;AAC5B,oDAAuB;AACvB,mCAAoC;AAEpC,MAAM,oBAAoB,GAAG,IAAI,mBAAG,CAAC;IACnC,GAAG,EAAE,EAAE;IACP,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;IACnB,cAAc,EAAE,IAAI;IACpB,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,CAAC,EAAC,qBAAqB,EAAC,EAAE,EAAE;QACnC,qBAAqB,EAAE,kBAAkB,EAAE,CAAC;IAC9C,CAAC;CACF,CAAC,CAAC;AACH,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC5C,MAAM,sBAAsB,GAAG,mBAAmB,CAAC;AACnD,MAAM,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAE/D;;;;;GAKG;AACH,SAAS,aAAa,CAAC,G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,cAAc,EAAE,EAAE;YAClF,IAAI,CAAC,cAAc,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE;gBAC5C,OAAO,IAAI,EAAE,CAAC;aACf;YACD,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAEO,8CAAiB"}
|
|
@@ -8,12 +8,13 @@ const IDEMPOTENT_RESPONSES = new LRU({
|
|
|
8
8
|
ttl: 30 * 60 * 1000,
|
|
9
9
|
updateAgeOnGet: true,
|
|
10
10
|
updateAgeOnHas: true,
|
|
11
|
-
dispose: (
|
|
11
|
+
dispose: ({responseStateListener}) => {
|
|
12
12
|
responseStateListener?.removeAllListeners();
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
const MONITORED_METHODS = ['POST', 'PATCH'];
|
|
16
16
|
const IDEMPOTENCY_KEY_HEADER = 'x-idempotency-key';
|
|
17
|
+
const MAX_CACHED_PAYLOAD_SIZE_BYTES = 1 * 1024 * 1024; // 1 MiB
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
*
|
|
@@ -33,25 +34,34 @@ function cacheResponse(key, req, res) {
|
|
|
33
34
|
response: null,
|
|
34
35
|
responseStateListener,
|
|
35
36
|
});
|
|
36
|
-
const
|
|
37
|
-
|
|
37
|
+
const socket = res.socket;
|
|
38
|
+
const originalSocketWriter = socket.write.bind(socket);
|
|
39
|
+
const responseRef = new WeakRef(res);
|
|
40
|
+
let responseChunks = [];
|
|
41
|
+
let responseSize = 0;
|
|
42
|
+
let errorMessage = null;
|
|
38
43
|
const patchedWriter = (chunk, encoding, next) => {
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
if (errorMessage || !responseRef.deref()) {
|
|
45
|
+
responseChunks = [];
|
|
46
|
+
responseSize = 0;
|
|
47
|
+
return originalSocketWriter(chunk, encoding, next);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const buf = Buffer.from(chunk, encoding);
|
|
51
|
+
responseChunks.push(buf);
|
|
52
|
+
responseSize += buf.length;
|
|
53
|
+
if (responseSize > MAX_CACHED_PAYLOAD_SIZE_BYTES) {
|
|
54
|
+
errorMessage = `The actual response size exceeds ` +
|
|
55
|
+
`the maximum allowed limit of ${MAX_CACHED_PAYLOAD_SIZE_BYTES} bytes`;
|
|
43
56
|
}
|
|
44
57
|
return originalSocketWriter(chunk, encoding, next);
|
|
45
58
|
};
|
|
46
|
-
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
res.once('close', () => {
|
|
53
|
-
if (res.socket?.write === patchedWriter) {
|
|
54
|
-
res.socket.write = originalSocketWriter;
|
|
59
|
+
socket.write = patchedWriter;
|
|
60
|
+
let didEmitReady = false;
|
|
61
|
+
res.once('error', (e) => {
|
|
62
|
+
errorMessage = e.message;
|
|
63
|
+
if (socket.write === patchedWriter) {
|
|
64
|
+
socket.write = originalSocketWriter;
|
|
55
65
|
}
|
|
56
66
|
|
|
57
67
|
if (!IDEMPOTENT_RESPONSES.has(key)) {
|
|
@@ -59,24 +69,53 @@ function cacheResponse(key, req, res) {
|
|
|
59
69
|
`Could not cache the response identified by '${key}'. ` +
|
|
60
70
|
`Cache consistency has been damaged`
|
|
61
71
|
);
|
|
62
|
-
} else
|
|
63
|
-
log.info(`Could not cache the response identified by '${key}': ${
|
|
72
|
+
} else {
|
|
73
|
+
log.info(`Could not cache the response identified by '${key}': ${errorMessage}`);
|
|
64
74
|
IDEMPOTENT_RESPONSES.delete(key);
|
|
65
|
-
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
responseChunks = [];
|
|
78
|
+
responseSize = 0;
|
|
79
|
+
if (!didEmitReady) {
|
|
80
|
+
responseStateListener.emit('ready', null);
|
|
81
|
+
didEmitReady = true;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
res.once('finish', () => {
|
|
85
|
+
if (socket.write === patchedWriter) {
|
|
86
|
+
socket.write = originalSocketWriter;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (!IDEMPOTENT_RESPONSES.has(key)) {
|
|
66
90
|
log.info(
|
|
67
|
-
`Could not cache the response identified by '${key}'
|
|
68
|
-
`
|
|
91
|
+
`Could not cache the response identified by '${key}'. ` +
|
|
92
|
+
`Cache consistency has been damaged`
|
|
69
93
|
);
|
|
70
|
-
|
|
94
|
+
} else if (errorMessage) {
|
|
95
|
+
log.info(`Could not cache the response identified by '${key}': ${errorMessage}`);
|
|
71
96
|
IDEMPOTENT_RESPONSES.delete(key);
|
|
72
97
|
}
|
|
73
98
|
|
|
74
99
|
const value = IDEMPOTENT_RESPONSES.get(key);
|
|
75
100
|
if (value) {
|
|
76
|
-
value.response = Buffer.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
101
|
+
value.response = Buffer.concat(responseChunks);
|
|
102
|
+
}
|
|
103
|
+
responseChunks = [];
|
|
104
|
+
responseSize = 0;
|
|
105
|
+
if (!didEmitReady) {
|
|
106
|
+
responseStateListener.emit('ready', value?.response ?? null);
|
|
107
|
+
didEmitReady = true;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
res.once('close', () => {
|
|
111
|
+
if (socket.write === patchedWriter) {
|
|
112
|
+
socket.write = originalSocketWriter;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (!didEmitReady) {
|
|
116
|
+
const value = IDEMPOTENT_RESPONSES.get(key);
|
|
117
|
+
responseStateListener.emit('ready', value?.response ?? null);
|
|
118
|
+
didEmitReady = true;
|
|
80
119
|
}
|
|
81
120
|
});
|
|
82
121
|
}
|
|
@@ -87,7 +126,7 @@ function cacheResponse(key, req, res) {
|
|
|
87
126
|
*/
|
|
88
127
|
async function handleIdempotency(req, res, next) {
|
|
89
128
|
const keyOrArr = req.headers[IDEMPOTENCY_KEY_HEADER];
|
|
90
|
-
if (!keyOrArr) {
|
|
129
|
+
if (_.isEmpty(keyOrArr) || !keyOrArr) {
|
|
91
130
|
return next();
|
|
92
131
|
}
|
|
93
132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/base-driver",
|
|
3
|
-
"version": "9.3.
|
|
3
|
+
"version": "9.3.20",
|
|
4
4
|
"description": "Base driver class for Appium drivers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"test:types": "tsd"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@appium/support": "^4.1.
|
|
48
|
-
"@appium/types": "^0.13.
|
|
47
|
+
"@appium/support": "^4.1.6",
|
|
48
|
+
"@appium/types": "^0.13.4",
|
|
49
49
|
"@colors/colors": "1.6.0",
|
|
50
50
|
"@types/async-lock": "1.4.0",
|
|
51
51
|
"@types/bluebird": "3.5.38",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "a01a91d7378fa1557c6a957026cf490d287752cc",
|
|
81
81
|
"typedoc": {
|
|
82
82
|
"entryPoint": "./lib/index.js"
|
|
83
83
|
},
|