diff options
Diffstat (limited to 'packages/db/src/core/integration/index.ts')
-rw-r--r-- | packages/db/src/core/integration/index.ts | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/packages/db/src/core/integration/index.ts b/packages/db/src/core/integration/index.ts index 21da2f761..986b2f84c 100644 --- a/packages/db/src/core/integration/index.ts +++ b/packages/db/src/core/integration/index.ts @@ -2,7 +2,6 @@ import { existsSync } from 'fs'; import { dirname } from 'path'; import { fileURLToPath } from 'url'; import type { AstroConfig, AstroIntegration } from 'astro'; -import { AstroError } from 'astro/errors'; import { mkdir, writeFile } from 'fs/promises'; import { blue, yellow } from 'kleur/colors'; import { loadEnv } from 'vite'; @@ -16,6 +15,7 @@ import { fileURLIntegration } from './file-url.js'; import { typegenInternal } from './typegen.js'; import { type LateSeedFiles, type LateTables, resolved, vitePluginDb } from './vite-plugin-db.js'; import { vitePluginInjectEnvTs } from './vite-plugin-inject-env-ts.js'; +import { AstroDbError } from '../../utils.js'; function astroDBIntegration(): AstroIntegration { let connectToStudio = false; @@ -145,10 +145,17 @@ function astroDBIntegration(): AstroIntegration { seedInFlight = true; const mod = server.moduleGraph.getModuleById(resolved.seedVirtual); if (mod) server.moduleGraph.invalidateModule(mod); - server.ssrLoadModule(resolved.seedVirtual).then(() => { - seedInFlight = false; - logger.info('Seeded database.'); - }); + server + .ssrLoadModule(resolved.seedVirtual) + .then(() => { + logger.info('Seeded database.'); + }) + .catch((e) => { + logger.error(e instanceof Error ? e.message : String(e)); + }) + .finally(() => { + seedInFlight = false; + }); } }, 100); }, @@ -161,7 +168,7 @@ function astroDBIntegration(): AstroIntegration { const message = `Attempting to build without the --remote flag or the ASTRO_DATABASE_FILE environment variable defined. You probably want to pass --remote to astro build.`; const hint = 'Learn more connecting to Studio: https://docs.astro.build/en/guides/astro-db/#connect-to-astro-studio'; - throw new AstroError(message, hint); + throw new AstroDbError(message, hint); } logger.info('database: ' + (connectToStudio ? yellow('remote') : blue('local database.'))); |