bun icon indicating copy to clipboard operation
bun copied to clipboard

Support SolidStart

Open paperclover opened this issue 1 year ago • 61 comments

Now that Vite (#250) is working, it's now time to start getting all of the vite-powered frameworks working.

The current blockers for SolidStart:

  • [ ] Dependency on node's --experiemntal-vm-modules flag
  • [x] Event loop bug causing the process to exit prematurely while loading es-module-loader https://github.com/oven-sh/bun/pull/3741

paperclover avatar Jul 22 '23 01:07 paperclover

Repro:

  • Go to a new directory
  • bun x create-solid@latest
  • Select either option regarding template (bare is the simplest Hello World example)
  • Select either option regarding SSR
  • Select either option regarding TypeScript
  • bun i
  • bun --bun run dev

birkskyum avatar Jul 22 '23 12:07 birkskyum

@birkskyum can you upgrade to canary and give it another try? bun upgrade --canary

Jarred-Sumner avatar Jul 22 '23 12:07 Jarred-Sumner

Update for canary (hash 3418feb2)

solid-start: 0.3.4 (Currently active version)

Result of above repro:

Cannot GET / instead of showing the Hello World page

In more advanced cases (an app I work on) I get this result now using both Bun and Node adapter:

error when starting dev server:
NotImplementedError: node:http2 createSecureServer is not yet implemented in Bun. Track the status & thumbs up the issue: https://github.com/oven-sh/bun/issues/887
    at new NotImplementedError (node:http2:14:10)
    at throwNotImplemented (node:http2:2:68)
    at createSecureServer (node:http2:25:22)

Blocked by

  • #8823

birkskyum avatar Jul 22 '23 12:07 birkskyum

Tried movies template of bunx create-solid ./my-solid-app, and it error with:

➜ bun --bun run dev -- --open
$ solid-start dev --open
 solid-start dev 
 version  0.3.2


error: Cannot find package "preact" from "file:///Users/admin/repos/my-solid-app/node_modules/local-pkg/index.mjs"

[bun] Warning: worker_threads.Worker option "execArgv" is not implemented.
  • #4075
  • #4130

birkskyum avatar Aug 13 '23 00:08 birkskyum

yes pls

We've ported a SS project over to bun, but get this

[solid] file:///Users/nikos/WebstormProjects/coffeeconnect/node_modules/solid-start/node/fetch.js:73
[solid] export class NodeRequest extends Request {
[solid]                                  ^

quantuminformation avatar Sep 12 '23 15:09 quantuminformation

Which adapter do you use?

birkskyum avatar Sep 12 '23 20:09 birkskyum

googles Node adapter

quantuminformation avatar Sep 13 '23 07:09 quantuminformation

any docs for adaptors?

quantuminformation avatar Sep 13 '23 10:09 quantuminformation

@quantuminformation , not sure I understand googles Node adapter - can you share your vite config?

birkskyum avatar Sep 13 '23 10:09 birkskyum

import solid from 'solid-start/vite';
import { defineConfig } from 'vite';
import dotenv from 'dotenv';

export default defineConfig(() => {
  dotenv.config();
  return {
    plugins: [solid()],
    test: {
      deps: {
        registerNodeLoader: true,
      },
      environment: 'jsdom',
      globals: true,
      setupFiles: ['node_modules/@testing-library/jest-dom/extend-expect'],
      transformMode: { web: [/\.[jt]sx?$/] },
    },
    ssr: {
      external: ['@prisma/client'],
    },
  };
});

quantuminformation avatar Sep 13 '23 10:09 quantuminformation

CleanShot 2023-09-13 at 14 57 47@2x

I get this when trying to run just a bare Solid Start project, with Bun 1.0.1.

It seems to launch the server, but because of the Streams error, it doesn't actually serve on localhost:3000

marcusbuffett avatar Sep 13 '23 12:09 marcusbuffett

@marcusbuffett, I believe it's this ticket - it's not implemented:

  • #4075
  • #4130

birkskyum avatar Sep 13 '23 13:09 birkskyum

@birkskyum I believe the worker thing isn't the main problem, it's the globalThis TypeError thing that's really breaking things – if I comment out that object assign, it serves pages

marcusbuffett avatar Sep 13 '23 13:09 marcusbuffett

my issue was fixed moving to node 18 from 16

quantuminformation avatar Oct 06 '23 08:10 quantuminformation

Tried to run an example of the upcoming solid-start release. It's still WIP, so I expected bugs, but interestingly this example does work fine in node, but breaks with bun:

solid-start/examples/bare on  vinxi [$!?] via ⬢ v18.19.0 took 4.1s 
➜ bun --bun run dev
$ vinxi dev
36 |     );
37 | }
38 | 
39 | export function defineConfig(baseConfig = {}) {
40 |   let { plugins = [], ssr = true, start = {}, ...userConfig } = baseConfig;
41 |   const extensions = [...DEFAULT_EXTENSIONS, ...(start.extensions || [])];
                            ^
ReferenceError: Cannot access uninitialized variable.
      at defineConfig (/Users/admin/repos/solid-start/packages/start/config/index.js:41:25)
      at evalModule (/Users/admin/repos/solid-start/node_modules/.pnpm/[email protected]/node_modules/jiti/dist/jiti.js:1:256441)
      at jiti (/Users/admin/repos/solid-start/node_modules/.pnpm/[email protected]/node_modules/jiti/dist/jiti.js:1:254369)
      at /Users/admin/repos/solid-start/node_modules/.pnpm/[email protected]/node_modules/c12/dist/index.mjs:288:15
      at resolveConfig (/Users/admin/repos/solid-start/node_modules/.pnpm/[email protected]/node_modules/c12/dist/index.mjs:234:29)
      at /Users/admin/repos/solid-start/node_modules/.pnpm/[email protected]/node_modules/c12/dist/index.mjs:116:39
      at loadConfig (/Users/admin/repos/solid-start/node_modules/.pnpm/[email protected]/node_modules/c12/dist/index.mjs:86:26)
      at /Users/admin/repos/solid-start/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/vinxi/lib/load-app.js:35:28
      at processTicksAndRejections (:61:76)

vinxi hook app:config-resolved                                                              3:10:47 AM
vinxi hook app:created 

It claims that DEFAULT_EXTENSIONS is uninitialized, but in the top of ./packages/start/config/index.js where the error happen, it's defined as:

const DEFAULT_EXTENSIONS = ["js", "jsx", "ts", "tsx"];

birkskyum avatar Dec 01 '23 02:12 birkskyum

There was a big new release on the solid-start side (@solidjs/start 0.4), but the error: ReferenceError: Cannot access uninitialized variable. was the same, and the initially presented reproduction instructions are still relevant as they now use this new version.

birkskyum avatar Dec 20 '23 17:12 birkskyum

As the latest version, it seems to be that ReferenceError: Cannot access uninitialized variable. is no longer an issue. The new error message I am getting is zlib.brotliCompress is not implemented. Could it be that this is the last missing piece of the puzzle to make this work?

Probably connected issue: https://github.com/oven-sh/bun/issues/267

itsyoboieltr avatar Dec 30 '23 13:12 itsyoboieltr

The only issue I still face is the server part of http2 missing when https is turned on in localhost (which is quite common). Otherwise everything runs - do any of you still experience issues with latest versions of start (>= 0.4.3) and vinxi (>= 0.1.1)?

birkskyum avatar Jan 05 '24 01:01 birkskyum

New versions seem to have fixed things here...

willpuckett avatar Jan 05 '24 04:01 willpuckett

Body parsing does not seem to work in solidstart production builds with bun (works with node): not sure if it is a bun or solidstart bug. Example code:

export const POST = async (event: APIEvent) => {
  console.log(await event.request.json());
  return new Response('ok');
};

The request hangs forever, instead of resolving. cc: @birkskyum

itsyoboieltr avatar Jan 05 '24 11:01 itsyoboieltr

If it works in node, it's to be considered a bug in bun - rule of thumb

birkskyum avatar Jan 05 '24 12:01 birkskyum

If it works in node, it's to be considered a bug in bun - rule of thumb

Unless, they are doing some if-else thing specifically to handle bun, which has a bug :) Since nitro seems to have a specific bun adapter and preset, I would assume those have a bug somewhere, since it is not node code that is running.

itsyoboieltr avatar Jan 05 '24 12:01 itsyoboieltr

Good point :)

birkskyum avatar Jan 05 '24 12:01 birkskyum

I am suspecting it is a h3 bug (or some h3 bun compatibility issue) since SolidStart uses h3 for api calls. Reproduction of the issue with Bun: solidstart-post-repro Issue opened for Vinxi (that makes builds for SolidStart): https://github.com/nksaraf/vinxi/issues/95

itsyoboieltr avatar Jan 05 '24 21:01 itsyoboieltr

now post requests also work! It was fixed on their end in: https://github.com/solidjs/solid-start/pull/1255?fbclid=IwAR3uo6IrPCogXb-qZPUrLjiKc-WrCj_WFjKEVgJ617j9gX4SZihmNjlQbmE Now everything seems to be working with SolidStart (dev, build, prod), so I guess the issue can finally be closed.

itsyoboieltr avatar Jan 14 '24 13:01 itsyoboieltr

The http2 server part is blocking for a lot of work with solid start apps as well as many other frameworks. It's not specific to this issue, but closing this before people confidently can use solid start does appear a bit too fast. I'd support closing it when it lands though.

birkskyum avatar Jan 14 '24 14:01 birkskyum

Tested solid start 0.6.0 which is just out (release notes).

Bun also breaks for single flight mutations:

➜ bun create solid

select solid-start, with typescript, notes example

➜ bun install
➜ bun --bun run dev
$ vinxi dev
vinxi v0.3.4
vinxi starting dev server

  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

1:01:59 AM [vite] ✨ new dependencies optimized: marked
1:01:59 AM [vite] ✨ optimized dependencies changed. reloading

Try to create a new note and save it - the server error is:

[h3] [unhandled] 1 | export default "native";
    ^
error: Unexpected end of JSON input
      at json (native:1:1)

1 | export default "native";
    ^
SyntaxError: Unexpected end of JSON input
      at json (native:1:1)

birkskyum avatar Feb 28 '24 00:02 birkskyum

Hit some error with missing crypto Diffie–Hellman

birkskyum avatar Apr 10 '24 22:04 birkskyum

With bun v1.1.3 (tested on Windows 11) I get this error when doing a "bun run --bun dev" on a SolidStart (v1.0 RC - Clown Town) project:

Segmentation fault at address 0x20 ???:?:?: 0x7ff7d1b2d621 in ??? (node.exe) ???:?:?: 0x7ff7d387d8b9 in ??? (node.exe) ???:?:?: 0x7ff7d212cd1f in ??? (node.exe) ???:?:?: 0x7ff7d21356a8 in ??? (node.exe) ???:?:?: 0x7ff7d208332e in ??? (node.exe) ???:?:?: 0x7ff7d20b6e0d in ??? (node.exe) ???:?:?: 0x7ff7d3802878 in ??? (node.exe) ???:?:?: 0x7ff7d1cb3cb7 in ??? (node.exe) ???:?:?: 0x7ff7d1d83b88 in ??? (node.exe) ???:?:?: 0x7ff7d37ce5da in ??? (node.exe) ???:?:?: 0x7ff7d16820c9 in ??? (node.exe) ???:?:?: 0x7ffd8bd8257c in ??? (KERNEL32.DLL) ???:?:?: 0x7ffd8d50aa47 in ??? (ntdll.dll)

paulo-assoc avatar Apr 11 '24 00:04 paulo-assoc

And with the latest bun canary I get:

[h3] [unhandled] 1 | export default "native"; ^ error: Unexpected end of JSON input at json (native:1:1)

1 | export default "native"; ^ SyntaxError: Unexpected end of JSON input at json (native:1:1)

The same error as @birkskyum, but still happening in the latest bun canary as of April 10.

paulo-assoc avatar Apr 11 '24 05:04 paulo-assoc