snnsnn
snnsnn
Explore posts from servers
SSolidJS
Created by Josesito on 1/18/2025 in #support
How does `query` cache actually work?
In Solid, because of the reactivity, changing route unloads the current component and loads the next one. This means whatever you did in the current route will be discarded. In other words, if you fetch the data for the next route, it will be discarded as well. The query function is a solution this problem. It store the data so that it won't be fetched again when the current route changes. The preload function will be associated with the corresponding route, and it will be called by the router component to fetch the data for that route. So, no need to check for location.pathname as it is designed to run when the path matches.
Preload function will be triggered when the user hovers over the link pointing to that route, assuming Router's preload prop is set to true. You can manually call the preload function, it will work the same. Sole purpose of the preload function is to fetch the data for the route. So, you should wrap the server function in a query and call it, otherwise the data you fetch will be discarded and fetched again when the route's component loads. That is why the value is cached for a short period of time. On the server side, query function store the queried value for the duration of a request. That way, if a query calls another query, the value will be fetched once. The data is stored on the rotuer. The request path is nothing to do with caching. Hope this clarifies your confusion.
16 replies
SSolidJS
Created by lacidar on 1/14/2025 in #support
solid styled starter template(solid-start) bug
That is because the style element is treated as text, not html. You need to make sure <style is not passed to or placed in its parent as text.
3 replies
SSolidJS
Created by snnsnn on 1/15/2025 in #support
Seeking Insights on SolidStart Server Function Issue
Thank you so much for your help in debugging the issue. Your explanation about how the server utilizes multiple workers for various capabilities really clarified the problem. It seems that the "Update value using Server Function" created an entirely new store in a different worker and updated that. Reflecting on the issue I opened, it is the textbook definition of data inconsistency across multiple workers. The docs should emphasize this behavior. Reading directly from a file and writing to it solved the issue. Turns out it’s not only that—the failing of the revalidation call after API updates was also tied to this issue. With the new logic, this now works as expected. Probably, revalidation was working as expected but was using the stale data. I wonder what the source of this behavior is—Nitro maybe? It would be great if they discussed the underlying architecture more or provided guidance to help people avoid running into these kinds of issues, saving time and frustration.
7 replies
SSolidJS
Created by snnsnn on 1/1/2025 in #support
Registering API Endpoints on SolidStart
Thanks, I know the event object has request, repsonse etc, but i am asking if there is a way to match a route, and parse query parameters, as I am trying to avoid external dependencies and manual work, and I see h3 router is not exposed: https://h3.unjs.io/guide/router
3 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Ok, thanks.
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I just realized I left out the most important detail. I was using functions/_middleware.js and that is the only middleware I use, so everything counts as function invocation, right?
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I was using it as an easy way to detect static assets, I can remove it. So, without it, there should be no cost then. For example:
export async function onRequest(ctx) {
const { pathname } = new URL(ctx.request.url);

if (pathname.endsWith('.css')) {
return await ctx.env.ASSETS.fetch(ctx.request.url);
}

return new Response(HTML, {
headers: { 'Content-Type': 'text/html' },
});
}
export async function onRequest(ctx) {
const { pathname } = new URL(ctx.request.url);

if (pathname.endsWith('.css')) {
return await ctx.env.ASSETS.fetch(ctx.request.url);
}

return new Response(HTML, {
headers: { 'Content-Type': 'text/html' },
});
}
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Without the middleware, I receive 404 for anything, including static assets.
9 replies
CDCloudflare Developers
Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I can not use a static index.html as I need to generate its content dynamically. I don't know how to serve it without a middleware.
9 replies
SSolidJS
Created by Bersaelor on 6/2/2023 in #support
How to keep/reuse DOM elements across routes?
That is how buitin components like For keep their elements between render cycles.
14 replies
SSolidJS
Created by Bersaelor on 6/2/2023 in #support
How to keep/reuse DOM elements across routes?
You can create your element in a seperate root, https://www.solidjs.com/docs/latest/api#createroot it wont get disposed.
14 replies
SSolidJS
Created by Obamax on 5/25/2023 in #support
Context not working as expected
Here is a detailed explanation on how context works: https://stackoverflow.com/a/74492899/7134134
15 replies
SSolidJS
Created by Obamax on 5/25/2023 in #support
Context not working as expected
You dont need to use contex for that, just import it as a module and use directly. Context is for those data you need overwrite at different levels of your component tree like theme, style value etc.
15 replies
SSolidJS
Created by Mathieu on 5/22/2023 in #support
Add a ref and make it also exposable
That is the easiest way
22 replies
SSolidJS
Created by Mathieu on 5/22/2023 in #support
Add a ref and make it also exposable
Call it inside fn
22 replies
SSolidJS
Created by Mathieu on 5/22/2023 in #support
Add a ref and make it also exposable
Pass callback function from parent
22 replies