Skip to content
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 src/constants/deploy.constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const MEMORY_SIZE_ENDPOINT_VERSION = '0.0.14';
export const MEMORY_HEAP_WARNING = 900_000_000n;

// Observed empirical value, the threshold might be higher, but at the time I wrote this, pagination there were a bit more than 700 files deployed on the Juno website without any issues.
Expand Down
25 changes: 22 additions & 3 deletions src/services/deploy.services.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import {satelliteMemorySize} from '@junobuild/admin';
import {satelliteMemorySize, satelliteVersion} from '@junobuild/admin';
import type {Asset} from '@junobuild/core';
import {listAssets as listAssetsLib} from '@junobuild/core';
import {yellow} from 'kleur';
import {compare} from 'semver';
import {readJunoConfig} from '../configs/juno.config';
import {DAPP_COLLECTION} from '../constants/constants';
import {DEPLOY_LIST_ASSETS_PAGINATION, MEMORY_HEAP_WARNING} from '../constants/deploy.constants';
import {
DEPLOY_LIST_ASSETS_PAGINATION,
MEMORY_HEAP_WARNING,
MEMORY_SIZE_ENDPOINT_VERSION
} from '../constants/deploy.constants';
import type {SatelliteConfigEnv} from '../types/config';
import {configEnv} from '../utils/config.utils';
import {confirmAndExit} from '../utils/prompt.utils';
import {NEW_CMD_LINE, confirmAndExit} from '../utils/prompt.utils';
import {satelliteParameters} from '../utils/satellite.utils';

export const assertSatelliteMemorySize = async (args?: string[]) => {
Expand All @@ -21,6 +27,19 @@ export const assertSatelliteMemorySize = async (args?: string[]) => {

const satellite = await satelliteParameters({satellite: satelliteConfig, env});

const currentVersion = await satelliteVersion({
satellite
});

if (compare(currentVersion, MEMORY_SIZE_ENDPOINT_VERSION) < 0) {
console.log(
`Your satellite (${yellow(
`v${currentVersion}`
)}) is not up-to-date, and the memory size cannot be verified.${NEW_CMD_LINE}`
);
return;
}

const maxMemorySize =
assertions?.heapMemory !== undefined && typeof assertions.heapMemory !== 'boolean'
? BigInt(assertions.heapMemory)
Expand Down