Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Aug 21, 2025

This PR addresses multiple architectural improvements and bug fixes based on user feedback:

🔧 Dependency Upgrades

  • Upgraded to Node 20 and pnpm 10.0.0
  • Updated all dependencies to latest stable versions:
    • Next.js 15.1.3
    • React 19.0.0
    • TanStack Query 5.62.7
    • MSW 2.7.0
    • TypeScript 5.7.2

📁 Mock Architecture Improvements

Reorganized mocking system to use .mock.ts naming convention:

Before:

src/mocks/handlers/profile.ts
src/mocks/handlers/accounts.ts
src/app/api/me/route.ts       // Next.js API routes
src/app/api/accounts/route.ts

After:

src/api/profile.mock.ts       // Mocks alongside API functions
src/api/accounts.mock.ts
  • Removed Next.js API routes entirely - only MSW for mocking
  • Mocks enabled by default in development via environment variables
  • Added MSW instrumentation for proper server-side setup

🐛 Critical Bug Fixes

Fixed Infinite API Calls in React 19 use() Hook

The original implementation was causing infinite /api/me calls:

// Problem: Creates new promise on every render
function ProfileContent() {
  const profile = use(getProfile()); // 🚫 New promise each time
}

// Solution: Memoize the promise
function ProfileContent() {
  const profilePromise = useMemo(() => getProfile(), []); // ✅ Stable reference
  const profile = use(profilePromise);
}

Hydration Warning Suppression

Added suppressHydrationWarning to HTML tag to prevent expected client/server differences.

🏗️ Build System Improvements

  • Removed unnecessary build steps - packages consumed directly as TypeScript
  • Updated .gitignore to exclude test artifacts (test-results/, playwright-report/)
  • Fixed dependency resolution for monorepo workspace packages

The application now builds successfully and demonstrates both data fetching patterns without infinite loops or build issues.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: jedateach <1356335+jedateach@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Implement the specification according the SPEC.md file at the root of the repo. Implement complete data fetching monorepo POC with React 19 use() hook and TanStack Query Aug 21, 2025
@Copilot Copilot AI requested a review from jedateach August 21, 2025 01:33
Copilot finished work on behalf of jedateach August 21, 2025 01:33
@jedateach
Copy link
Owner

@copilot - thanks, I have tested out the code, and would like the following changes:

  • Upgrade to Node 20, Pnpm 10 and to the latest stable version of each dependency. Verify this works before proceeding with the rest of my requests.

  • Mocks and api implementations are too spread out. Introduce a .mock.ts naming standard for mocks that sit right next to each api file.

  • Mocks should be enabled by default when running in development, but use environment variables to have them disabled in a production build (or optionally in dev via local env overrides). I don't want the next server api responses we should only use msw for mocking.

  • don't commit test results or reports to the codebase. So I don't want the test-results or playwright-report folders.

  • Check the .gitignore file matches the structure of this repo.

  • Unless you can explain otherwise, I don't think packages need to be built, and should be directly consumable as typescript. If so, then remove that building.

  • There is a bug I can see where the /api/me call is being made indefinitely. Please ensure that has gone.

  • Suppress the hydration warning on the main html tag.

Copilot AI and others added 3 commits August 21, 2025 02:33
…ks, fix infinite API calls, suppress hydration warnings

Co-authored-by: jedateach <1356335+jedateach@users.noreply.github.com>
…, and bug fixes

Co-authored-by: jedateach <1356335+jedateach@users.noreply.github.com>
Co-authored-by: jedateach <1356335+jedateach@users.noreply.github.com>
Copy link
Author

Copilot AI commented Aug 21, 2025

@copilot - thanks, I have tested out the code, and would like the following changes:

  • Upgrade to Node 20, Pnpm 10 and to the latest stable version of each dependency. Verify this works before proc...

All requested changes have been implemented successfully! ✅

Key Changes Made:

🔧 Dependencies & Environment:

  • Upgraded to Node 20 (added .nvmrc)
  • Upgraded to pnpm 10.0.0
  • Updated all dependencies to latest stable versions (Next.js 15.1.3, React 19.0.0, TanStack Query 5.62.7, MSW 2.7.0, TypeScript 5.7.2, etc.)

📁 Mock Organization:

  • Moved mocks to .mock.ts files alongside API files:
    • src/api/profile.mock.ts
    • src/api/accounts.mock.ts
  • Removed Next.js API routes completely - only MSW for mocking
  • Mocks enabled by default in development via environment variables

🏗️ Build & Repository:

  • Updated .gitignore to exclude test-results/ and playwright-report/
  • Removed unnecessary build steps - packages consumed directly as TypeScript
  • All packages now point to src/index.ts instead of built dist/ files

🐛 Bug Fixes:

  • Fixed infinite /api/me calls by memoizing promises in React 19 use() hook
  • Added suppressHydrationWarning to HTML tag
  • Fixed dependency resolution and build issues

The application builds successfully and all functionality works as expected! The commit hash is 23b2990.

@Copilot Copilot AI changed the title Implement complete data fetching monorepo POC with React 19 use() hook and TanStack Query Upgrade dependencies, reorganize mocks, and fix React 19 use() hook infinite loop Aug 21, 2025
Copilot finished work on behalf of jedateach August 21, 2025 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants