I've come across a very weird issue. For reference, my project uses Astro in SSR mode with Solid. I have one .tsx component, which uses the createResource module for API request handling. The excerpt of my code:
import { Suspense, createResource, createSignal } from "solid-js"
const [response] = createResource(formData, postFormData)
This all works great - apart from the very first time I run npm run start. At this first instance, I get Vite errors stating
|- TypeError: Cannot read properties of undefined (reading 'id')
at Proxy.createResource (file://./node_modules/solid-js/dist/server.js:438:35)
at eval (eval at instantiateModule (file:///./node_modules/vite/dist/node/chunks/dep-e8f070e8.js:54402:28), <anonymous>:20:42)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async instantiateModule (file:///./node_modules/vite/dist/node/chunks/dep-e8f070e8.js:54405:9)```
This error points at the server.js provided by Solid, inside the section for the createResource module:
```js
const sharedConfig = {};
function setHydrateContext(context) {
sharedConfig.context = context;
}
const SuspenseContext = createContext();
let resourceContext = null;
function createResource(source, fetcher, options = {}) {
const id = sharedConfig.context.id + sharedConfig.context.count++;
^ it errors right here
}```
The way I currently solve this is by commenting out the `const [response = ...` line and saving, letting Vite reload the site which now errors due to undefined values (obv), then I uncomment the line and save again, vite reloads and the page works from now on, until I kill the `astro dev` session. This wasnt an issue during development, but now that I'm trying to host the page, I think its causing problems with pageload.