Files
65a0c87b2f Release v2.5.1 (#3174)
* fail the app start if multichain config or essential dapps config were not generated properly

* add timeouts for essential dapps and multichain config generators

* fix "add to wallet" button in address tokens table

* [skip ci] update docs

* fix tx tables when there are no fee and value columns

* add support for promoted multichain provider

* fixes

* change action button logic

* fix tests

* fix

* hide "add network" button for multichain

* shorten the amount of txs on multichain homepage

* change name formatting for multichain button

* add bright color variants and lg size for badges

* fix y-axis margin calculation for chart with custom tick formatter

* superchain bug fixes

* bump versions of react and nextjs

* update screenshot

* bump dappscout-iframe

* increase timeouts for multichain and essential dapps config generators

---------

Co-authored-by: Max Alekseenko <[email protected]>
2025-12-11 11:30:55 +01:00

60 lines
1.6 KiB
TypeScript

/* eslint-disable no-console */
import { parentPort, workerData } from 'node:worker_threads';
interface WorkerData {
url: string;
}
interface ChainConfig {
envs: Record<string, string>;
}
async function fetchChainConfig(url: string): Promise<ChainConfig> {
const controller = new AbortController();
const timeout = setTimeout(() => {
controller.abort(`Request to ${ url } timed out`);
}, 30_000);
try {
const response = await fetch(`${ url }/node-api/config`, { signal: controller.signal });
if (!response.ok) {
throw new Error(`Failed to fetch config from ${ url }: ${ response.statusText }`);
}
const config = await response.json();
return config as ChainConfig;
} catch (error) {
throw error;
} finally {
clearTimeout(timeout);
}
}
async function computeConfig() {
try {
const { url } = workerData as WorkerData;
console.log(' ⏳ Fetching chain config from:', url);
// 1. Fetch chain config
const chainConfig = await fetchChainConfig(url);
// 2. Set environment variables
Object.entries(chainConfig.envs).forEach(([ key, value ]) => {
// eslint-disable-next-line no-restricted-properties
process.env[key] = value;
});
// 3. Import and compute app config
const { 'default': appConfig } = await import('configs/app/index');
console.log(' ✅ Config computed for:', url);
// 4. Send config back to main thread
parentPort?.postMessage(appConfig);
} catch (error) {
console.error(' ❌ Worker error:', error);
process.exit(1);
}
}
computeConfig();