peerreynders
Solid Start Vinxi complaining about public and can't resolve public fonts
You can suppress the message with this
app.config.ts
:
https://rollupjs.org/configuration-options/#external
That way it will only complain about files you haven't added yet (warning you of potential misspellings).8 replies
Solid Start Vinxi complaining about public and can't resolve public fonts
Given that font files are not bundled, no. What's important is that they can be located at runtime.
You can use
preload
to give the browser a hint that it will need the font files.8 replies
How does `query` cache actually work?
Even if the routes get loaded from different browsers.The
query
values exist within the client side JS scope of the browser tab; so each browser, even browser tab, will issue a separate request creating their own isolated query
values.
Now if you navigate inside the same browser tab within the 5 secs window to the second route, I assume that the query
request won't be repeated.
The query
values live here16 replies
Solid Start Vinxi complaining about public and can't resolve public fonts
- Created and installed fresh SolidStart(TS) "basic" project.
- moved
src/app.css
to src/styles/app.css
- adjusted import './styles/app.css';
in src/app.tsx
- copied Geist-SemiBold.woff2
into public/fonts
- modified src/styles/app.css
:
- $ pnpm run dev
and visit http://localhost:3000/
. It works.
- $ pnpm run build
. You'll see a bunch of
-/fonts/Geist-SemiBold.woff2
referenced in/fonts/Geist-SemiBold.woff2
didn't resolve at build time, it will remain unchanged to be resolved at runtime
$ node .output/server/index.mjs
and visit http://localhost:3000/
. It works.8 replies
How does `query` cache actually work?
Just to add to what has already been stated.
These are two separate requests:
but more importantly
initiates it's own RPC request based on the route parameter.
You can can still use
createAsync(() => getProduct('foo'))
and createAsync(() => getProduct('thang'))
on the same route/page, each issuing their own, independent request.
But getProduct
takes an argument. query
values are partitioned by a hash key based on the arguments that are used to acquire them.
That's why it is important to use the query
's keyFor
to target the correct partitioned value that is stored under the query
.
At the end of an action
would only rerun the query
function for 'foo'
but not for 'thang'
(driving components connected to the 'foo'
value but not components connected to the 'thang'
value).16 replies
How does `query` cache actually work?
A
query
value is considered "fresh" for 5 seconds. All components drawing their data from that query
within 5 seconds will be served the same data from the initial request. Should any component connect after 5 seconds, an entirely new request is run.
https://github.com/solidjs/solid-router/blob/50c5d7bdef6acc5910c6eb35ba6a24b15aae3ef6/src/data/query.ts#L15-L16
For use in the context of bfcache
every 5 minutes query
values older than 3 minutes are completely removed.16 replies
How does `query` cache actually work?
That's not entirely accurate. The intention is that the
query
value is "global" for the duration of the "route request"; i.e. until the route data settles after navigation to that route.
After that action
s can respond with data for multiple query
s in a single request (aka single flight mutation).16 replies
How does `query` cache actually work?
-
action
s tend to mutate server state that will require some query
s on the route to rerun. At the end of an action
revalidate
is used to refresh the relevant query
s.
- When a query
is refreshed all the components on the route depending on it will receive the up-to-date data.
- These action
s can send the fresh data for the affected query
s in their response body; this is referred to as singleflight mutations.16 replies
How does `query` cache actually work?
It's a mistake to view
query
in isolation.
- To some degree the aim is for the route to be able to load all the data that may be needed by every component that is on it's page.
- From that perspective query
helps to decouple the aquisition of data from the component consuming it. The component then can simply access the data it needs via createAsync
.
- So more than one component on the page can consume that data without multiple fetches. This is the "request deduping". More fundamentally this "1 to N
fan-out", i.e. 1 set of data driving N
components has some benefit later with actions
. The data can be shared among components without going through context
.
- At least with Solid 1.x the query
/ createAsync
seam establishes the "asynchronous value" to "synchronous reactivity" boundary into Solid's reactive graph where you compose reactive primitives. query
deals with the "value asynchronously" while createAsync
makes that value accessible via a reactive accessor.
- Ideally you'll want to "warm up" all the query
s on the route in the route's preload
. As soon as the cursor hovers over a link to the route the preload
query
s will start their loading process in an attempt to shorten the loading time when the route's link is clicked.16 replies
Best Practices for Handling Errors in a query-Wrapped Server Function
Rely on thrown errors for unrecoverable problemshttps://discord.com/channels/722131463138705510/1274312740378251287/1274319949585973309
7 replies
Best Practices for Handling Errors in a query-Wrapped Server Function
The important feature is that the
Error
is returned, not thrown.
This means that in the login.tsx
route we can use the latest submission;
to obtain the most recent error from the submission record to display the error:
So either the login succeeds and you are navigated to /
or the Error
message is simply displayed in the current /login
page.7 replies
Best Practices for Handling Errors in a query-Wrapped Server Function
Finally the
login.tsx
route uses loginOrRegister
:
Again there are only two outcomes:
- resolve to an Error
instance
- reject with a redirect
compelling the client side router to navigate to /
7 replies
Best Practices for Handling Errors in a query-Wrapped Server Function
Now there is a counterpart:
This is part of the login route
preload
:
This ensures that you are automatically navigated from /login
to /
if there is an authenticated session.7 replies
Best Practices for Handling Errors in a query-Wrapped Server Function
There are only two outcomes, either:
- resolve to the user info
- reject with a
redirect
compelling the client side router to navigate to /login
(or simply stay there)
getUser()
is used on the lop level Layout
:
This accomplishes two things:
- it makes the user
accessor available to show the correct "Login" vs. "Logout"
- but more importantly it always throws a redirect('/login')
whenever there isn't an active account ID in the session cookie. So you either stay on the /login
page or you will get navigated to the /login
page.7 replies
Best Practices for Handling Errors in a query-Wrapped Server Function
TL;DR: Return
Error
s; throw redirect
s
I assume this comes from the with-auth example.
To be honest that version doesn't make a lot of sense to me as the "User not found " Error
would simply get swallowed in favour of the thrown redirect.
Instead have a look at how the strello
app handles it with a more distributed approach:
7 replies