Skip to content

Troubleshooting Guide

This guide covers common issues you might encounter during development and their solutions.

Issue: Wrong Node.js version causing build failures or dependency issues.

Symptoms:

  • npm install fails with version warnings
  • Build process throws unexpected errors
  • Different behavior between local and CI

Solution:

Terminal window
# Check current version
node --version
# Switch to project version
nvm use # or asdf local nodejs $(cat .nvmrc)
# For asdf users, set this environment variable
export ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY=latest_available
# Clean install dependencies
npm run fresh

Issue: Environment variables are undefined or not accessible.

Symptoms:

  • undefined values for environment variables
  • Server-side variables not accessible in client
  • Build failures related to missing config

Solutions:

  1. Check file naming: Ensure .env.local exists (not .env.example)
  2. Verify Astro config: Add variables to astro.config.mjs:
    env: {
    schema: {
    SERVER_MY_SECRET: {
    context: "server",
    access: "secret",
    },
    PUBLIC_MY_VAR: {
    context: "client",
    access: "public",
    },
    },
    },
  3. Check variable naming: Server variables need SERVER_ prefix, client variables need PUBLIC_ prefix
  4. Restart dev server after changing environment variables

Issue: Development server won’t start due to port conflicts.

Symptoms:

  • EADDRINUSE error on port 3000
  • Server starts but shows wrong content

Solution:

Terminal window
# Kill processes on port 3000
lsof -ti:3000 | xargs kill -9
# Or use different port
npm run dev -- --port 3001

Issue: Mismatched server island rendering causing hydration errors.

Symptoms:

  • Console errors about server island mismatches
  • Components not hydrating correctly
  • Inconsistent rendering between server and client

Solution:

Terminal window
# Ensure ASTRO_KEY is set in .env.local
echo "ASTRO_KEY=your-secret-key-here" >> .env.local
# Restart development server
npm run dev

Issue: TypeScript errors about missing GraphQL types.

Symptoms:

  • Import errors for generated types
  • TypeScript compilation failures
  • Missing query type definitions

Solutions:

  1. Run codegen: npm run codegen
  2. Check GraphQL endpoint: Verify CAPI connection in .env.local
  3. Verify query files: Ensure .cms.graphql files are properly formatted
  4. Clear cache: Delete node_modules and reinstall

Issue: Changes not reflecting in browser during development.

Symptoms:

  • Need to manually refresh browser
  • Styles not updating
  • Component changes not appearing

Solutions:

  1. Check file extensions: Ensure proper .astro, .tsx, .ts extensions
  2. Restart dev server: npm run dev
  3. Clear browser cache: Hard refresh with Cmd+Shift+R (Mac) or Ctrl+Shift+R (Windows)
  4. Check file watchers: Increase system file watcher limits if needed

Issue: Interactive components not working in browser.

Symptoms:

  • Buttons don’t respond to clicks
  • State changes don’t trigger updates
  • Console errors about hydration mismatches

Solutions:

  1. Check client directives: Ensure proper client:load, client:visible, or client:idle usage
  2. Verify component exports: Ensure proper default exports in .tsx components
  3. Check for SSR/hydration mismatches: Ensure server and client render same content
  4. Review error boundaries: Add proper error handling in components

Issue: Tailwind classes or custom styles not working.

Symptoms:

  • Components appear unstyled
  • Design tokens not resolving
  • Styles work in Storybook but not in app

Solutions:

  1. Check Tailwind config: Verify tailwind.config.mjs includes all content paths
  2. Verify design token imports: Check CSS imports in components
  3. Check mode attributes: Ensure proper data-theme and data-mode attributes
  4. Clear build cache: Delete dist/ and rebuild

Issue: Images not displaying or loading slowly.

Symptoms:

  • Broken image placeholders
  • Slow image loading
  • Imgix parameters not working

Solutions:

  1. Check image URLs: Verify Imgix domain configuration
  2. Review image component: Ensure proper ImgixImage component usage
  3. Check loading strategies: Verify loading="lazy" for below-fold images
  4. Verify image formats: Ensure supported formats (WebP, AVIF, JPG)

Issue: Build process takes excessively long.

Symptoms:

  • npm run build takes several minutes
  • CI/CD pipelines timing out
  • Local development builds slow

Solutions:

  1. Analyze bundle: Use npm run analyze to identify large dependencies
  2. Check dynamic imports: Ensure proper code splitting
  3. Review image optimization: Check for unoptimized large images
  4. Update dependencies: Ensure latest versions of build tools

Issue: JavaScript bundles are too large.

Symptoms:

  • Slow page load times
  • High Lighthouse scores for performance
  • Large network requests

Solutions:

  1. Run bundle analyzer: npm run analyze
  2. Implement code splitting: Use dynamic imports for large components
  3. Tree shake unused code: Review and remove unused dependencies
  4. Optimize images: Use proper image formats and sizes

Issue: PR preview environments not deploying or accessible.

Symptoms:

  • 404 errors on ephemeral URLs
  • Build succeeds but site not accessible
  • Wrong content showing on preview

Solutions:

  1. Check branch naming: Ensure branch name follows alphanumeric + hyphen convention
  2. Wait for deployment: Allow up to 5 minutes after GitHub Actions completion
  3. Check GitHub Actions: Review build logs for errors
  4. Verify environment variables: Ensure nonprod secrets are properly configured

Issue: Production deployments failing or showing errors.

Symptoms:

  • Build failures in GitHub Actions
  • 500 errors on production site
  • Missing environment variables in production

Solutions:

  1. Check GitHub Actions logs: Review detailed error messages
  2. Verify production secrets: Ensure AWS Parameter Store configuration
  3. Test production build locally: Run npm run build && npm run start:server
  4. Check for environment-specific code: Ensure no hardcoded local values

Issue: Accessibility tests failing or violations detected.

Symptoms:

  • Axe DevTools showing violations
  • Screen reader navigation problems
  • Keyboard navigation not working

Solutions:

  1. Review ARIA attributes: Ensure proper labeling and roles
  2. Check semantic HTML: Use proper heading hierarchy and landmarks
  3. Test keyboard navigation: Ensure all interactive elements are focusable
  4. Run automated tests: Use Astro Dev Tools accessibility panel

Issue: Storybook not starting or components not rendering.

Symptoms:

  • Storybook build failures
  • Components showing as blank
  • Story controls not working

Solutions:

  1. Check story files: Ensure proper .stories.tsx format
  2. Verify component exports: Check default exports in component files
  3. Review Storybook config: Check .storybook/ configuration files
  4. Clear Storybook cache: Delete Storybook cache and restart

If you’re still experiencing issues after trying these solutions:

  1. Search documentation: Check relevant guides in this documentation
  2. Check recent changes: Review recent PRs that might have introduced issues
  3. Ask the team: Post in #lp-frontend Slack channel with:
    • Clear description of the problem
    • Steps to reproduce
    • Error messages or screenshots
    • What you’ve already tried
  4. Create an issue: For persistent bugs, create a GitHub issue with detailed reproduction steps
Terminal window
# Check versions
node --version
npm --version
# Clear all caches
npm run fresh
rm -rf dist/
# Verbose logging
npm run dev:logger
# Build analysis
npm run analyze
# Check for type errors
npx tsc --noEmit
# Lint issues
npm run lint
# Check Astro configuration
npx astro check