oneiro
Set headers inside createServerAction$()
Hey folks,
I am currently trying to explicitely set my content type header to
Content-Type: application/json; charset=utf-8
because of some encoding issues.
However I don't quite understand how I can do so inside a call of createServerAction$()
.
I tried to access responseHeaders from useRequest()
, however they seem to be always undefined:
Any idea, what I am doing wrong here?
Thanks in advance3 replies
Best way to dynamically access i18n-translations with typescript
Hey folks,
I am currently using @solid-primitives/i18n (https://github.com/solidjs-community/solid-primitives/tree/main/packages/i18n#readme) for translation purposes.
However there's one thing i struggle with:
Some of the keys I would like to access are coming from an api, where each key is typed as generic string.
For example imagine that my dict looks like this:
And I want to translate like this:
This of course makes typescript complain, as we can't be sure here that our key does actually exist inside the dict.
What would be the best way to go about this here?
I imagine I would need some form of wrapper around
t()
that still retains its api, but e.g. returns an empty string or throws an error if the key is not part of the dict.
Are there any best practices how to deal with that?
Thanks in advance 🙂1 replies
What's the best way to debug `Buffer is not defined`
Hey folks,
I am currently trying to re-restructure my code a bit, so it becomes more maintainable. One thing I noticed, is that I sometimes receive a
Buffer is not defined
runtime error inside the browser when moving things.
This happened for example, when I accidentally put a module inside one of my routes sub-directories which wasn't a module and just contained some stuff to be consumed. However I also seem to get the issue, when I export server-specific functions in various places.
Generally there seem to be various sources leading to this error.
Is there a good way to debug this and to make finding the cause of the issue easier than carefully reading my code and using trial and error?
Thanks in advance!3 replies
What is the proper way to start solid-start in production (especially with something like pm2)?
Hey folks,
I am currently running solid-start in production with a docker compose setup. Solid start is being run by first producing a build with running
solid-start build
and then invoking solid-start start
.
Is this the proper way to run solid-start in production?
Is there a way to just run the output from solid-start build
? When running something with pm2 for example you typically provide a single javascript file as script
entrypoint. How would I do that with solid-start?
I want to start clustering my application. But before I use something large like kubernetes for scaling, I want to use pm2 inside my docker-container.
Thanks in advance 🙂7 replies
Best way to upload files from a form with solid-start?
Hey folks,
I was wondering what the best way to upload a file with solid-start would be?
Is there an easy way to use
createServerAction$
or should I expose an API-route?
(I couldn't really find any fully fledged examples, so if you know any, I would be very happy if you'd share them with me 🙂 )
Thanks in advance!8 replies
Easiest way to spin up an e2e/integration-test setup with solid-start?
Hey folks,
I am currently trying to figure out what would be a good way to build an integration and e2e-testing setup for solid-start.
Essentially my integration tests should be able to connect to a database and only test server-side logic (for UI stuff I would simply use testing-library). E2E-tests should spin up a database as well as the solid-start application.
Now here are the hurdles I have yet to overcome:
1. I would definitely like to use docker to spin up my database (we use docker-compose for our dev setup anyway). Ideally in conjunction with test containers. However our database connection is currently initalized via environment variables from an
.env
-file and with testcontainers I am unsure how I would ideally overwrite these after our database has been imported
(this would be necessary, as testcontainers use a random port and I would also need to get the host)
2. What would be the best/easiest way to start my server. Ofcourse I could also run my solid-start app inside another container, but that feels a bit more exessive than I would like. Ideally I could start the server without the need for a container from my tests.
So my general question would probably be: what do your integration/e2e-testsetups generally look like, when working with solid-start?
Thanks in advance 🙂2 replies
Suspense not updating when navigating to Route directly
Hey folks,
I am currently having a weird issue I can't quite solve:
We have a route which receives data via
routeData
+ createServerData$
. The routes JSX is wrapped with <Suspense />
.
Now when I navigate to this route from another route, our data
will be set correctly and <Suspense />
will eventually resolve.
However when I simply type the url in to my browser and navigate directly to the route, suspense will never resolve.
data()
keeps being undefined
. I logged inside createServerData
and the data seems to be correctly accumulated on the server, I just does not seem to be served to the client.
Anything obvious I am missing here?
Thanks in advance
PS: I will try to create a minimal reproducable example asap - I just wanted to get this question ouf beforehand in case there's something obvious I am doing wrong 🙂3 replies
solid-transition-group leads to reactivity warning inside test cases
Hey folks,
we just started using solid-transition-group and as soon as the
<Transition />
-component is present, all of our test cases start throwing the computations created outside a createRoot or render will never be disposed
- error.
If we remove the transition the error disappears. Any idea what could cause this?
The component in question looks like this:
Thanks in advance6 replies
Issue with event delegation and a native library
Hey folks,
I am currently trying to integrate a command palette library into our app. I tried various libraries and eventually ended up with solid-ninja-keys/ninja-keys. However there is one issue: solid-ninja-keys seems to be just a small wrapper around ninja-keys, ninjakeys itself seems to reliy on regular input events (e.g. keydown). Now when I have something with a keydown handler in my app (in my case it's a select field from solid-select) ninja-keys will no longer work (you can press cmd + k and the overlay appears, but all other shortcuts won't work).
I have recreated the issue here: https://stackblitz.com/edit/solidjs-templates-dz5buc?file=src%2FApp.tsx
So now I am wondering two things:
1. is there an easy way to fix this?
2. How hard is it in general to integrate regular js libraries into solid - is it as "hard" as in react or as "easy" as with svelte (I've only used react for many years and jumped to solid instead of svelte, but heard that svelte is pretty strong in that regard)
Thanks in advance
25 replies
Testing portals
Hey,
I am currently trying to test a datepicker created with https://github.com/rnwonder/solid-date-picker with testing-libary.
However I am not quite sure how to select the actual picker. It seems to get rendered into a div with the id
portal-island
, which also shows up in my test, but without its contents.
What would be the general way to test this? I also tried to jsut use querySelector
but am not sure, how to get the correct container element to attach the querySelector to.
Thanks in advance16 replies
Is the createUniqueId-helper safe to use?
We are currently using the createUniqueId-helper on the client only and today one of our data entries was overwritten. We are relatively sure, that this was because its ID was generated a second time when we created a new data entry. Can id clashes happen? Ids are rather short, so I imagine that this is definitely a possibility.
Would it be better to switch to something like nanoid here, which can be configured to use a longer id?
4 replies
Are global signals ever reset between test runs?
@lexlohr Sorry - another issue 😅
As I've described in another issue I have structured my application in a way, that my global state mainly consists of global stores.
Now to create tests I usually need to first populate my stores with some test data. This does seem to work fine in general, howerver I noticed, that apparently these stores will keep their state between tests. Is this a mistake on my end, am I using stores wrong, or is this a bug?
21 replies
Access native html dialogs show/close methods in clickHandler
Hey folks,
I am currently using native html dialogs inside my app and am accessing their show/close methods by using them from window (e.g.
window.myModal.show()
). However this is pretty error prone and also doesn't play well with testing.
Is there a recommended way on how to use these without accessing the window? I thought of using refs
but apparently these refs are not set, when my handler functions are created, so they stay undefined. 🤔
Ideally I would export show/close functions from my component file that could be used everywhere througout the app.
Any idea what would be a good way to solve this?15 replies
Is there a way to debug how callbacks are called, when firing an event with testing-library?[SOLVED]
Hey,
I am having a hard time testing my code and would like to find out if and how some of my event handlers are actually being called, when I run
(continuation in thread)
fireEvent.click()
on a button.
Some background: I am running solid inside a Tauri-Application which works very well.
However my issue is, that on the click of a button nothing observable seems to happen (it works perfectly fine in the real running application).
Basically what I am trying to do, is to setup some stores, render my app, find a button that should start a timer, advance these timers by using vitests fake timers and afterwards inspect, that a stop button is being rendered and the time has been adjusted accordingly.
My current (simplified without timers) test looks like this:
(continuation in thread)
9 replies
solidjs/testing-library using `location` but still getting <Router /> error
Hey,
I am currently trying to setup on of my solid-apps with solidjs/testing-library. I want to test something on my main route, and am therefore using the
location
option. However my test still throws the Make sure your app is wrapped in a <Router />
-error.
Any idea what I could be doing wrong?
Here's my test wip test case:
And here's the top level component I am testing:
33 replies
Solid-testing library TS-eslint-errors
Hey<
I am just starting out using solids testing library and setup my project according to this example: https://github.com/solidjs/solid-start/tree/main/examples/with-vitest/src
However I am getting some TS-errors I am not quite sure how to resolve correctly.
My
Counter.test.tsx
looks exactly like in the example:
However on the destructor of queryByRole
I receive the following error:
Furhtermore on the call to queryByRole
I receive an error, that queryByRole does not return a Promise and is therefore not awaitable.
Is this an error on my part or is this an error already present inside the example repo?
Thanks in advance11 replies
Solid-start client side state best practices
Hey folks,
I noticed that the docs are still missing the section on the various kinds of application state.
Therefore I wanted to ask here what is considere to be a good approach to handle state after hydration.
Example:
We use
createServerData
to build our initial route data. But after hydration we would like to have the state globally available.
What would be the best approach to do this? Should we simply take the data and put it in a store
or is there another recommended approach?
Thanks in advance3 replies
How "beta" is SolidStart?
Hey, sorry for the weird phrasing of the question.
I am currently starting a new small customer project and was wondering if it would be worth checking out solidStart for this.
However the beta disclaimer (while appreciated) is a bit discouraging.
Would you say that solidstart is already usable enough for a real world project and that APIs are somewhat stable, or will I shoot myself in the foot by using it right now?
If the latter is the case, are there other recommended approaches to do SSR with Solid right now?
Thanks in advance
3 replies
Confused about resource mutation with `createDeepSignal` and `produce`
Hey folks,
I am trying to create a resource which gets updated on a button click, by fetching content from a server.
However the user may change parts of the data they have already fetched. When refetching the data, we want to make sure that all user changes are not being overwritten.
To allow changing small parts of the data and still being reactive, I use
createDeepSignal
from solid-primitives.
My resource is initiated like this:
Store here is a persisted file.
By default this file is empty until the user fetches projects from a remote server for the first time.
This fetch function can be used repeatedly and should alter its behaviour depending on if the user already has fetched projects or not as described above.
My fetch function looks like this: (continuation in comment)20 replies