Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add no-async-promise-executor as it becames recommanded #15261

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ module.exports = {
'no-extra-boolean-cast': 'error',
'no-irregular-whitespace': 'error',
'no-constant-binary-expression': 'error',
'no-async-promise-executor': 'error',
'no-empty': 'error',
'no-prototype-builtins': 'error',
'@typescript-eslint/no-empty-object-type': 'off',
Expand Down
39 changes: 19 additions & 20 deletions packages/suite-desktop-core/e2e/support/regtest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,30 @@ export const generateBlock = () =>
method: 'GET',
});

export const waitForCoinjoinBackend = () =>
new Promise<void>(async (resolve, reject) => {
const limit = 60;
const error = '';
export const waitForCoinjoinBackend = async () => {
const limit = 60;
const error = '';

console.log('waiting for coinjoin backend');
console.log('waiting for coinjoin backend');

for (let i = 0; i < limit; i++) {
if (i === limit - 1) {
console.log(`waiting for coinjoin backend: ${error}\n`);
}
for (let i = 0; i < limit; i++) {
if (i === limit - 1) {
console.log(`waiting for coinjoin backend: ${error}\n`);
}

await new Promise(resolve => setTimeout(() => resolve(undefined), 1000));
await new Promise(resolve => setTimeout(() => resolve(undefined), 1000));

try {
const res = await fetch('http://localhost:19121/');
if (res.status === 200) {
console.log('coinjoin backend is online');
try {
const res = await fetch('http://localhost:19121/');
if (res.status === 200) {
console.log('coinjoin backend is online');

return resolve();
}
} catch {
process.stdout.write('.');
return;
}
} catch {
process.stdout.write('.');
}
}

reject(error);
});
throw error;
};
62 changes: 30 additions & 32 deletions packages/trezor-user-env-link/src/websocket-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,41 +267,39 @@ export class WebsocketClient extends TypedEmitter<WebsocketClientEvents> {
this.removeAllListeners();
}

waitForTrezorUserEnv() {
return new Promise<void>(async (resolve, reject) => {
// unfortunately, it can take incredibly long for trezor-user-env to start, we should
// do something about it
const limit = 300;
let error = '';

console.log('waiting for trezor-user-env');

for (let i = 0; i < limit; i++) {
if (i === limit - 1) {
console.log(`cant connect to trezor-user-env: ${error}\n`);
async waitForTrezorUserEnv() {
// unfortunately, it can take incredibly long for trezor-user-env to start, we should
// do something about it
const limit = 300;
let error = '';

console.log('waiting for trezor-user-env');

for (let i = 0; i < limit; i++) {
if (i === limit - 1) {
console.log(`cant connect to trezor-user-env: ${error}\n`);
}
await delay(1000);

try {
const res = await fetch(USER_ENV_URL.DASHBOARD);
if (res.status === 200) {
console.log('trezor-user-env is online');

return;
}
await delay(1000);

try {
const res = await fetch(USER_ENV_URL.DASHBOARD);
if (res.status === 200) {
console.log('trezor-user-env is online');

return resolve();
}
} catch (err) {
error = err.message;
// using process.stdout.write instead of console.log since the latter always prints also newline
// but in karma, this code runs in browser and process is not available.
if (typeof process !== 'undefined') {
process.stdout.write('.');
} else {
console.log('.');
}
} catch (err) {
error = err.message;
// using process.stdout.write instead of console.log since the latter always prints also newline
// but in karma, this code runs in browser and process is not available.
if (typeof process !== 'undefined') {
process.stdout.write('.');
} else {
console.log('.');
}
}
}

reject(error);
});
throw error;
}
}
Loading