Skip to content

fix: various lifecycle issues#77

Merged
XiNiHa merged 2 commits into
mainfrom
fix/lifecycles
May 28, 2026
Merged

fix: various lifecycle issues#77
XiNiHa merged 2 commits into
mainfrom
fix/lifecycles

Conversation

@XiNiHa
Copy link
Copy Markdown
Owner

@XiNiHa XiNiHa commented May 28, 2026

Closes #74
Closes #75

Action Items From #74:

Items

  • 1. createResource.storage is used as a place to wire subscriptions. The documented purpose of storage is signal substitution, not subscription wiring. — not an issue, but an intentionally hacky workaround
  • 2. createFragment finally cleanup is gated on isServer, so the client error path leaks observeFragment subscriptions. — 152e41d
  • 3. createLazyLoadQuery.storage launches a void (async () => …) loop with no stale-check; the loop keeps writing to replaySubject after the owner is gone. — not an issue since the purpose of that callback is to stream all the data fetched from the server into the client Relay environment, which should happen even when the owner is gone
  • 4. queryCache inner Map has no eviction policy, and entry === null entries are stored permanently. — c3026c5
  • 5. runWithOwner is not used anywhere in the codebase, even at the call sites that subscribe outside the synchronous owner phase. The canonical Solid pattern (used by createResource itself for refetch) is missing. — unowned code paths don't seem to create anything that should be owned
  • 6. setSubscription(...) overwrites the previous Subscription signal without unsubscribing it first; the previous subscription becomes unreachable but alive. — 152e41d
  • 7. createPaginationFragment can have concurrent createFetchTracker instances during rapid loadNext calls before the previous one is disposed. — separate issue (needs reproduction first)

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 28, 2026

🦋 Changeset detected

Latest commit: 152e41d

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

This PR includes changesets to release 1 package
Name Type
solid-relay Patch

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

Open in StackBlitz

npm i https://pkg.pr.new/solid-relay@77

commit: 3f72862

@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.66%. Comparing base (d761604) to head (152e41d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #77      +/-   ##
==========================================
+ Coverage   91.40%   91.66%   +0.26%     
==========================================
  Files          20       20              
  Lines         733      732       -1     
  Branches      140      140              
==========================================
+ Hits          670      671       +1     
+ Misses         55       53       -2     
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue where queries that were not fetched were still being cached. It updates the QueryCacheEntry type to exclude null and moves the cache insertion logic inside the shouldFetch conditional block. The reviewer suggests making the resource property optional in QueryCacheEntry to support retaining queries even when they are not fetched (e.g., for store-only policies).

Comment thread src/queryCache.ts
Comment on lines 4 to +7
export type QueryCacheEntry = {
resource: Resource<unknown>;
retain: (environment: IEnvironment) => Disposable;
} | null;
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

To support retaining queries even when they are not fetched (e.g., for store-only or store-or-network policies when data is already available), we should make the resource property optional in QueryCacheEntry. This allows us to cache and retain the query without needing to create a dummy resource.

Suggested change
export type QueryCacheEntry = {
resource: Resource<unknown>;
retain: (environment: IEnvironment) => Disposable;
} | null;
};
export type QueryCacheEntry = {
resource?: Resource<unknown>;
retain: (environment: IEnvironment) => Disposable;
};

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 28, 2026

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
solid-relay 152e41d Commit Preview URL

Branch Preview URL
May 28 2026, 05:20 AM

@XiNiHa XiNiHa marked this pull request as ready for review May 28, 2026 05:19
@XiNiHa XiNiHa merged commit d685bbc into main May 28, 2026
4 of 5 checks passed
@XiNiHa XiNiHa deleted the fix/lifecycles branch May 28, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant