Skip to content

Conversation

@ENvironmentSet
Copy link
Collaborator

Data caching must be done in dedicated data fetching/synching layer such as relay and tanstack DB. We're not going to tackle this problem on our own.

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

🦋 Changeset detected

Latest commit: ff59bb4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 14 packages
Name Type
@stackflow/react Major
@stackflow/config Major
@stackflow/docs Patch
@stackflow/demo Patch
@stackflow/compat-await-push Major
@stackflow/link Major
@stackflow/plugin-basic-ui Major
@stackflow/plugin-google-analytics-4 Major
@stackflow/plugin-history-sync Major
@stackflow/plugin-map-initial-activity Major
@stackflow/plugin-preload Major
@stackflow/plugin-renderer-basic Major
@stackflow/plugin-renderer-web Major
@stackflow/react-ui-core Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 15, 2025

Deploying stackflow-demo with  Cloudflare Pages  Cloudflare Pages

Latest commit: ff59bb4
Status: ✅  Deploy successful!
Preview URL: https://edbcd47a.stackflow-demo.pages.dev
Branch Preview URL: https://loader-cache-as-opt-in-featu.stackflow-demo.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Dec 15, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
stackflow-docs ff59bb4 Commit Preview URL Dec 15 2025, 07:21 AM

@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Breaking Changes

    • Removed data loader caching functionality. Activity loaders will no longer cache results between requests.
  • Chores

    • Major version bump for @stackflow/react and @stackflow/config.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This PR removes the data loader cache mechanism from the Stackflow library. It eliminates the loaderCacheMaxAge property from the ActivityLoader type, simplifies the loader function signature by removing the options parameter, and removes all cache retrieval, storage, and invalidation logic from the React integration.

Changes

Cohort / File(s) Summary
Version & Changelog
.changeset/real-cats-rest.md
Adds changeset marking major version bumps for @stackflow/react and @stackflow/config with note "Remove data loader cache".
ActivityLoader Simplification
config/src/ActivityLoader.ts
Removes loaderCacheMaxAge property from the ActivityLoader type. Removes the optional options parameter from the loader function and simplifies the implementation to directly return a wrapper function without object merging.
Cache Logic Removal
integrations/react/src/future/stackflow.tsx
Removes the global DEFAULT_LOADER_CACHE_MAX_AGE constant, cache map, and all associated caching operations including cache retrieval, entry creation, updates, and invalidation. Simplifies loadData to compute loaderData without cache reuse or invalidation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify all references to loaderCacheMaxAge are removed throughout the codebase
  • Confirm that removing cache-related logic doesn't introduce unintended side effects or performance regressions
  • Check if related tests require updates to reflect the simplified loader behavior

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing first-class data loader cache from config and react packages.
Description check ✅ Passed The description is directly related to the changeset, explaining the rationale for removing the data loader cache and referencing dedicated data fetching layers.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch loader-cache-as-opt-in-feature

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 15, 2025

commit: ff59bb4

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
config/src/ActivityLoader.ts (2)

11-11: Consider returning loaderFn directly.

The wrapper function (args: ActivityLoaderArgs<ActivityName>) => loaderFn(args) is unnecessary since loaderFn already matches the ActivityLoader<ActivityName> signature.

Apply this diff to simplify:

-  return (args: ActivityLoaderArgs<ActivityName>) => loaderFn(args);
+  return loaderFn;

4-6: Consider using a generic type parameter for the return type.

The any return type reduces type safety. Consider adding a generic type parameter to improve type inference for consumers.

Example refactor:

-export type ActivityLoader<ActivityName extends RegisteredActivityName> = (
-  args: ActivityLoaderArgs<ActivityName>,
-) => any;
+export type ActivityLoader<
+  ActivityName extends RegisteredActivityName,
+  TReturn = any,
+> = (args: ActivityLoaderArgs<ActivityName>) => TReturn;

-export function loader<ActivityName extends RegisteredActivityName>(
-  loaderFn: (args: ActivityLoaderArgs<ActivityName>) => any,
-): ActivityLoader<ActivityName> {
+export function loader<
+  ActivityName extends RegisteredActivityName,
+  TReturn = any,
+>(
+  loaderFn: (args: ActivityLoaderArgs<ActivityName>) => TReturn,
+): ActivityLoader<ActivityName, TReturn> {
   return (args: ActivityLoaderArgs<ActivityName>) => loaderFn(args);
 }

As per coding guidelines, TypeScript should be written with strict typing enabled.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 23ced9d and ff59bb4.

📒 Files selected for processing (3)
  • .changeset/real-cats-rest.md (1 hunks)
  • config/src/ActivityLoader.ts (1 hunks)
  • integrations/react/src/future/stackflow.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • integrations/react/src/future/stackflow.tsx
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md

📄 CodeRabbit inference engine (AGENTS.md)

Include a Changeset entry for any user-facing package change

Files:

  • .changeset/real-cats-rest.md
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Write source in TypeScript with strict typing enabled across the codebase

Files:

  • config/src/ActivityLoader.ts
config/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

For the Future API, define activities and routes in @stackflow/config using defineConfig(), keeping component injection separate

Files:

  • config/src/ActivityLoader.ts
🧬 Code graph analysis (1)
config/src/ActivityLoader.ts (2)
config/src/RegisteredActivityName.ts (1)
  • RegisteredActivityName (3-6)
config/src/ActivityLoaderArgs.ts (1)
  • ActivityLoaderArgs (6-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Workers Builds: stackflow-docs
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
.changeset/real-cats-rest.md (1)

1-6: LGTM! Changeset properly documents the breaking changes.

The changeset correctly marks major version bumps for both affected packages (@stackflow/react and @stackflow/config) and provides a clear description of the change. The version bump types align with the breaking nature of removing first-class data loader cache functionality.

config/src/ActivityLoader.ts (1)

4-6: LGTM! Type definition correctly simplified.

The removal of the loaderCacheMaxAge property and simplification to a plain function type aligns with the PR objective to remove first-class data loader cache functionality.

@irrationnelle irrationnelle self-assigned this Dec 15, 2025
Copy link
Collaborator

@irrationnelle irrationnelle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not know why loadData function should be placed in stackflow.tsx. The operation of current loadData function is very plain, therefore this operation could be moved away but I could not ensure where this operation should belong to.

We should consider of this later. Approved

@ENvironmentSet ENvironmentSet merged commit 29a0bb6 into main Dec 15, 2025
9 checks passed
@ENvironmentSet ENvironmentSet deleted the loader-cache-as-opt-in-feature branch December 15, 2025 13:20
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.

3 participants