Skip to content

Commit

Permalink
use vanilla axios
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Sep 20, 2023
1 parent 00613e6 commit c8f1e8f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/uiautomator2.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ class UiAutomator2Server {
async cleanupAutomationLeftovers (strictCleanup = false) {
this.log.debug(`Performing ${strictCleanup ? 'strict' : 'shallow'} cleanup of automation leftovers`);

const axiosTimeout = 500;

const waitStop = async () => {
// Wait for the process stop by sending a status request to the port.
// We observed the process stop could be delayed, then it caused the process stop
Expand All @@ -314,9 +316,13 @@ class UiAutomator2Server {
try {
await waitForCondition(async () => {
try {
await this.adb.processExists(SERVER_TEST_PACKAGE_ID);
await axios({
url: `http://${this.host}:${this.systemPort}/status`,
timeout: axiosTimeout,
});
} catch (err) {
return true;
} catch (ignore) {}
}
}, {
waitMs: timeout,
intervalMs: 100,
Expand All @@ -329,7 +335,7 @@ class UiAutomator2Server {
try {
const {value} = (await axios({
url: `http://${this.host}:${this.systemPort}/sessions`,
timeout: 500,
timeout: axiosTimeout,
})).data;
const activeSessionIds = value.map(({id}) => id).filter(Boolean);
if (activeSessionIds.length) {
Expand Down

0 comments on commit c8f1e8f

Please sign in to comment.