taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 98c188c1b14f73a6b81f41a0cacd6195bb53208e
parent aa39162de0bba9b7673db5214012efee1ea61f15
Author: Florian Dold <florian@dold.me>
Date:   Thu, 16 May 2024 01:28:44 +0200

-move config value to not break UI code

Diffstat:
Mpackages/taler-util/src/wallet-types.ts | 12+++++++++++-
Mpackages/taler-wallet-cli/src/index.ts | 7+++----
Mpackages/taler-wallet-core/src/wallet.ts | 4++--
3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/packages/taler-util/src/wallet-types.ts b/packages/taler-util/src/wallet-types.ts @@ -487,6 +487,7 @@ export interface PartialWalletRunConfig { builtin?: Partial<WalletRunConfig["builtin"]>; testing?: Partial<WalletRunConfig["testing"]>; features?: Partial<WalletRunConfig["features"]>; + lazyTaskLoop?: Partial<WalletRunConfig["lazyTaskLoop"]>; } export interface WalletRunConfig { @@ -520,8 +521,17 @@ export interface WalletRunConfig { */ features: { allowHttp: boolean; - lazyTaskLoop: boolean; }; + + /** + * Start processing tasks only when explicitly required, even after + * init has been called. + * + * Useful when the wallet is started to make single read-only request, + * as otherwise wallet-core starts making network request and process + * unrelated pending tasks. + */ + lazyTaskLoop: boolean; } export interface InitRequest { diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts @@ -29,6 +29,7 @@ import { encodeCrock, getErrorDetailFromException, getRandomBytes, + InitRequest, j2s, Logger, NotificationType, @@ -284,9 +285,7 @@ async function createLocalWallet( "native-init", { config: { - features: { - lazyTaskLoop: args.lazyTaskLoop, - }, + lazyTaskLoop: args.lazyTaskLoop, testing: { devModeActive: checkEnvFlag("TALER_WALLET_DEV_MODE"), denomselAllowLate: checkEnvFlag( @@ -296,7 +295,7 @@ async function createLocalWallet( skipDefaults: walletCliArgs.wallet.skipDefaults, }, }, - }, + } satisfies InitRequest, ); return res; } catch (e) { diff --git a/packages/taler-wallet-core/src/wallet.ts b/packages/taler-wallet-core/src/wallet.ts @@ -756,7 +756,7 @@ async function dispatchRequestInternal( versionInfo: getVersion(wex), }; - if (req.config?.features?.lazyTaskLoop) { + if (req.config?.lazyTaskLoop) { logger.trace("lazily starting task loop"); } else { await wex.taskScheduler.ensureRunning(); @@ -1720,7 +1720,6 @@ export function applyRunConfigDefaults( }, features: { allowHttp: wcp?.features?.allowHttp ?? false, - lazyTaskLoop: false, }, testing: { denomselAllowLate: wcp?.testing?.denomselAllowLate ?? false, @@ -1730,6 +1729,7 @@ export function applyRunConfigDefaults( skipDefaults: wcp?.testing?.skipDefaults ?? false, emitObservabilityEvents: wcp?.testing?.emitObservabilityEvents ?? false, }, + lazyTaskLoop: wcp?.lazyTaskLoop ?? false, }; }