Repository navigation
feat(agera): export createScope to stop a deferred scope whose body threw - #309
Merged
Merged
Conversation
… threw `deferScope` hands its scope back only when the body returns, so a body that throws leaves what it created linked to the stores it read. A scope from `createScope`, given to `deferScope` as the parent, stops it either way. The `parent` of `deferScope` is a scope handle now, as `createScope` returns.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #309 +/- ##
==========================================
- Coverage 83.62% 83.60% -0.03%
==========================================
Files 228 228
Lines 4849 4849
Branches 1074 1074
==========================================
- Hits 4055 4054 -1
Misses 553 553
- Partials 241 242 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
deferScopehands its scope back only when the body returns. A body that throws loses the handle, and what it created before the throw stays linked to the stores it read, with nothing left to stop it. The upcoming@nanoviews/serverrenders a whole app in a deferred scope and stops it as soon as the markup is written, so a failed request would leave its computeds and effects subscribed to every store that outlives the request. Today it catches the error inside the body to get the handle back, stops the scope and throws the error again.With
createScopethe render runs in a scope created under one made beforehand, and stopping that one stops the render either way:What
ageraexportscreateScope(parent?), andkidaand@nano_kit/storere-export it. It is the functiondeferScopeandboundDeferScopealready make their scopes with, so a bundle that uses either gets no new code.DeferredScope, the handle the other scope functions work with. TheparentofdeferScopeis aDeferredScopenow instead of aReactiveNode: nothing in this repo or in nanoviews passes one, and the scope functions are@internal.createScopeis stopped with its parent.Size
ageraAll publics (Gzip)ageraAll publics (Brotli)kidaAll publics (Gzip)kidaAll publics (Brotli)@nano_kit/storeAll publics (Gzip)@nano_kit/storeAll publics (Brotli)Only the name of the export is new. The Brotli size of
@nano_kit/storemoves by 48 B where its Gzip size moves by 3 B, which is compression noise, but it no longer fits the old limit.Signal,Minimal setandPopular setare unchanged in every package.Verification
oxlint,tsc --noEmitandvitestare clean inagera.tsc --noEmitpasses inkida,@nano_kit/store,@nano_kit/queryand@nano_kit/devtools, andsize-limitpasses inagera,kidaand@nano_kit/store.