Skip to content

Commit 6215605

Browse files
committed
fix: retryconfigfor must be implemented per class
1 parent 53cfcb6 commit 6215605

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

injected/src/features/autofill-import.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,11 @@ export default class AutofillImport extends ActionExecutorBase {
609609
}
610610
}
611611

612-
get retryConfig() {
612+
/**
613+
* Here we ignore the action and return a default retry config
614+
* as for now the retry doesn't need to be per action.
615+
*/
616+
retryConfigFor(_) {
613617
return {
614618
interval: { ms: 1000 },
615619
maxAttempts: 30,
@@ -629,7 +633,7 @@ export default class AutofillImport extends ActionExecutorBase {
629633
// Ideally we should be usuing standard messaging in Android, but we are not ready yet
630634
// So just patching the notify method to post a message to the Android side
631635
this.messaging.notify = this.postBookmarkImportMessage.bind(this);
632-
return this.processActionAndNotify(action, {}, this.retryConfig);
636+
return this.processActionAndNotify(action, {});
633637
}
634638

635639
async handleBookmarkImportPath(pathname) {

injected/src/features/broker-protection.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ export class ActionExecutorBase extends ContentFeature {
77
/**
88
* @param {any} action
99
* @param {Record<string, any>} data
10-
* @param {any} retryConfig
1110
*/
12-
async processActionAndNotify(action, data, retryConfig) {
11+
async processActionAndNotify(action, data) {
1312
try {
1413
if (!action) {
1514
return this.messaging.notify('actionError', { error: 'No action found.' });
1615
}
1716

18-
const { results, exceptions } = await this.exec(action, data, retryConfig);
17+
const { results, exceptions } = await this.exec(action, data);
1918

2019
if (results) {
2120
// there might only be a single result.
@@ -51,10 +50,10 @@ export class ActionExecutorBase extends ContentFeature {
5150
* later analysis
5251
* @param {any} action
5352
* @param {Record<string, any>} data
54-
* @param {any} retryConfig
5553
* @return {Promise<{results: ActionResponse[], exceptions: string[]}>}
5654
*/
57-
async exec(action, data, retryConfig) {
55+
async exec(action, data) {
56+
const retryConfig = this.retryConfigFor(action);
5857
const { result, exceptions } = await retry(() => execute(action, data, document), retryConfig);
5958

6059
if (result) {
@@ -63,7 +62,7 @@ export class ActionExecutorBase extends ContentFeature {
6362
const nextExceptions = [];
6463

6564
for (const nextAction of result.success.next) {
66-
const { results: subResults, exceptions: subExceptions } = await this.exec(nextAction, data, retryConfig);
65+
const { results: subResults, exceptions: subExceptions } = await this.exec(nextAction, data);
6766

6867
nextResults.push(...subResults);
6968
nextExceptions.push(...subExceptions);
@@ -74,6 +73,13 @@ export class ActionExecutorBase extends ContentFeature {
7473
}
7574
return { results: [], exceptions };
7675
}
76+
77+
/**
78+
* @returns {any}
79+
*/
80+
retryConfigFor(action) {
81+
this.log.error('unimplemented method: retryConfigFor:', action);
82+
}
7783
}
7884

7985
/**
@@ -83,7 +89,7 @@ export default class BrokerProtection extends ActionExecutorBase {
8389
init() {
8490
this.messaging.subscribe('onActionReceived', async (/** @type {any} */ params) => {
8591
const { action, data } = params.state;
86-
return await this.processActionAndNotify(action, data, this.retryConfigFor(action));
92+
return await this.processActionAndNotify(action, data);
8793
});
8894
}
8995

0 commit comments

Comments
 (0)