gornostay25 / svelte-adapter-bun

A SvelteKit adapter for Bun
MIT License
537 stars 34 forks source link

Error Fetching PageData during Client-Side Route Transition #29

Open ismail424 opened 1 year ago

ismail424 commented 1 year ago

When using the Bun adapter with SvelteKit, I encounter an internal 500 error during client-side navigation (when pressing on a "a tag with href").

The error seems related to fetching PageData for that route.

It works fine if I refresh the page but when I navigate to it with client-side-navigation it gives me the error.

Steps to Reproduce:

1. Set up a SvelteKit project with the Bun adapter.
2. Create a route that returns PageServerLoad via the load function from +page.server.ts/js
3. Create a +page.ts/js and fetch that data
4. Navigate to the route using client-side navigation, can be an "a tag" with href to that route.
Observe an internal 500 error when SvelteKit attempts to fetch the data for the page.

Expected Behavior:

 Client-side navigation should work without errors, and PageData should be fetched successfully.
 Actual Behavior:
 Internal 500 error occurs, with the response: {"message":"Internal Error"}. 
 Then it console logs the following: {"originalLine":273,"originalColumn":18}.

Additional Information: Request URL causing the issue: http://localhost:3000/settings/__data.json?x-sveltekit-invalidated=0011 SvelteKit version: latest Bun adapter version: 0.5.0

Error Logs:

 Console Output: {"originalLine":273,"originalColumn":18}
 Server Response: {"message":"Internal Error"}

Screenshots (if applicable): Screenshot_20230916_223517 Screenshot_20230916_223744

maietta commented 1 year ago

What was the solution?

ismail424 commented 1 year ago

I actually don't know, When I created a new project using bun create svelte@latest my-app and ran a demo app. It magically fixed the problem but I think some datatypes are not allowed to be returned from PageData or something like that. I am currently trying to debug it to se what is causing the problem.

This down bellow is a example code from the demo app that works. 🤔 image

ismail424 commented 1 year ago

It was a problem with a datatype that was returnered, It was a 'Invalid date' (Error) that was accidently returned.

notramo commented 1 month ago

@ismail424, could you test this again? It seems it is a Bun Node compatibility error, which is likely resolved since.