-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support AdonisJS 6 #4822
Comments
Current AdonisJS 6 fails to run because of Tracking: #808 |
Running on Linux (#1843 (comment)) seems to get a bit further. Ace seems to run, and can run some commands. However, server is still not running ( Running ace:![]() Running ace commands:![]() Running server (doesn't work):![]() |
The bun upgrade --canary Now running the ace command line breaks directly with the error Running directly the bun bin/server.ts
[0.78ms] ".env"
221 | const callback = args[args.length - 1];
222 | if (typeof callback !== "function")
223 | @throwTypeError("Callback must be a function");
224 | fs.readdir(...args).then((result) => callback(null, result), callback);
225 |
226 | }, readFile = function readFile2(...args) {
^
TypeError: Invalid path string: can't be empty
code: "ERR_INVALID_ARG_TYPE"
at readFile2 (node:fs:226:64)
at /Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:60:6
at new Promise (:1:20)
at _getFrameSource (/Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:59:11)
at /Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:95:17
at /Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:91:31
at map (:1:20)
at /Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:91:8
at new Promise (:1:20)
at _parseError (/Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:88:11)
at /Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:323:6
at new Promise (:1:20)
at toJSON (/Users/romainlanz/workspace/lab/bun-test/node_modules/youch/src/Youch.js:322:11)
at /Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/core/build/index.js:33:38
at processTicksAndRejections (:55:76) It seems to be linked to an issue of Bun not sending back a file path when parsing the stack trace (using stacktracey). poppinss/youch#49 This is maybe due to Bun having a different format to display stack trace. https://github.com/xpl/stacktracey/blob/master/stacktracey.js#L49 - #185 |
Monkey patching the bun bin/server.ts
[1.13ms] ".env"
TypeError: undefined is not an object (evaluating 'router.get') This is probably due to a different way of initializing ESM modules. The code that is breaking is: import router from '@adonisjs/core/services/router'
router.get('/', async () => 'It works!') The import app from './app.js';
let router;
/**
* Returns a singleton instance of the router class from
* the container
*/
await app.booted(async () => {
router = await app.container.make('router');
});
export { router as default }; |
It also appears to randomly fail on some bun bin/server.ts
[0.20ms] ".env"
TypeError: undefined is not an object (evaluating 'callers')
⁃ fixTarget
node_modules/pino/lib/transport.js:129
⁃ <anonymous>
node_modules/pino/lib/transport.js:93
⁃ transport
node_modules/pino/lib/transport.js:90 The function transport (fullOptions) {
const { pipeline, targets, levels, dedupe, options = {}, worker = {}, caller = getCallers() } = fullOptions
// Backwards compatibility
const callers = typeof caller === 'string' ? [caller] : caller
console.log(callers)
// ... Bun outputs [
'file:///Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/logger/build/src/pino.js',
'file:///Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/logger/build/src/logger.js',
'file:///Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/logger/build/src/logger_manager.js',
'file:///Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/core/build/providers/app_provider.js'
] Tracking: #4280 |
@RomainLanz see the latest comment in #4280, with a small hackfix pino runs nicely in bun |
This fixed it, but yeah, it is a hack fix since having an I still have some random ESM loading issues (see #4822 (comment)) bun bin/server.ts
[1.70ms] ".env"
[0.00ms] ".env"
TypeError: undefined is not an object (evaluating 'router.get')
at module code start/routes.ts:2
1| /*
❯ 2| |--------------------------------------------------------------------------
3| | Routes file
4| |--------------------------------------------------------------------------
5| |
6| | The routes file is used for defining the HTTP routes.
7| | But running it another time seems to be good for the core of the framework! bun bin/server.ts
[0.71ms] ".env"
[0.00ms] ".env"
[11:38:34.865] INFO (81972): started HTTP server on localhost:3333 |
This bug is fixed in #4693 |
I'm unable to to start it up, even using the bun canary build
|
Yes, it still does not work well with Please, look at the latest comment of #4280 (comment). |
Just attempted with latest version of bun (1.0.3)
I get the message "It works!" in the browser. |
With version bun bin/server.ts
TypeError: undefined is not an object (evaluating 'router.get')
at module code start/routes.ts:13
8| */
9|
10| import HellosController from '#controllers/hellos_controller'
11| import router from '@adonisjs/core/services/router'
12|
❯ 13| router.get('/', async () => 'It works!')
14| router.get('/hello', [HellosController, 'greet'])
15|
We cannot run the bun ace.js serve --watch
error: expected ":" separator -- Trying out Dependency Injection, Bun seems not to emit metadata, making it unusable. import { inject } from '@adonisjs/core';
import HelloService from '#services/hello_service';
@inject()
export default class HellosController {
constructor(private helloService: HelloService) { }
greet() {
return this.helloService.hello('world');
}
} This is causing the code to fail because bun bin/server.ts
[12:40:52.521] INFO (69034): started HTTP server on 0.0.0.0:3333
[12:41:04.535] ERROR (69034): Cannot construct "[class HellosController]" class. Container is not able to resolve its dependencies
request_id: "tkkwx1bcn7h2ce96u0xkarzn"
x-request-id: "tkkwx1bcn7h2ce96u0xkarzn"
err: {
"type": "RuntimeException",
"message": "Cannot construct \"[class HellosController]\" class. Container is not able to resolve its dependencies",
"stack":
Error: Cannot construct "[class HellosController]" class. Container is not able to resolve its dependencies
at new Exception (/Users/romainlanz/workspace/lab/bun-test/node_modules/@poppinss/utils/build/index.js:43:50)
at new RuntimeException (:1:33)
at createError (/Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/fold/build/index.js:293:36)
at <anonymous> (/Users/romainlanz/workspace/lab/bun-test/node_modules/@adonisjs/fold/build/index.js:365:12)
at asyncFunctionResume (native)
at promiseReactionJobWithoutPromiseUnwrapAsyncContext (native)
at promiseReactionJob (native)
at processTicksAndRejections (native)
"name": "RuntimeException",
"status": 500,
"code": "E_RUNTIME_EXCEPTION"
} |
Tried with version Flaky TLA import issue is still there though. |
Interestingly, if you add
Look related to: #5277 |
The following commit will probably fix ESM loading issue: oven-sh/WebKit@00ae02e |
The next version of Bun should arrive next Tuesday. |
With Bun bun bin/server.ts
TypeError: undefined is not an object (evaluating 'router.get')
at module code start/routes.ts:13
8| */
9|
10| import HellosController from '#controllers/hellos_controller'
11| import router from '@adonisjs/core/services/router'
12|
❯ 13| router.get('/', async () => 'It works!')
14| router.get('/hello', [HellosController, 'greet'])
15| |
Bun |
Same with |
Tested today on WSL2 with the steps above and it seems to start up fine. OS: Windows 10 |
It's a flaky behaviour. Run
Tested with bun |
macOS 14.1 (Sonoma) |
I just tested on macos 13.5.1 and also was unable to reproduce. I'll test out using more features to see if I can reproduce later when I have some time. |
I can confirm that it is still not working on Bun bun ./bin/server.ts
TypeError: undefined is not an object (evaluating 'router.get') @Banashek Are you doing anything special to make it work? I am on a macOS Sonoma 14.0. |
I will check to create a proper issue with a reproduction so the Bun team can address the bug. |
I was getting mixed results with Seems like it's some sort of cache / build / signature issue perhaps. When I first installed it and ran it, I received the same issue as @RomainLanz
Which then turn into the issue you see in the video of:
And then became a mixed bag of working / not working. I started commenting pieces how to see how far the app would get before an error, and that's when it worked / failed / worked again in both commented and uncommented scenarios. Later in the video (0:53) there's another new error which is interesting because I'm not changing anything significant in how I'm testing it.
Screen.Recording.2023-11-28.at.10.18.19.AM.mov.mp4 |
I tried Bun
|
Tracking subpath import: #10001 |
Side note, it is still flacky on macOS with version If anyone want to try it. 👍🏻 |
Isn't the subpath import fixable by just doing the same imports in tsconfig.json? BTW how did you get rid of the Any progress on this? |
There is no need to replicate the imports in the
I am not running the code through |
But if you want to run I got as far as trying
|
Yes, we have to troubleshoot further why Ace command do not work. Also, we are soon releasing an HMR feature for our CLI, meaning you will not have to use |
I actually made some progress. The
Because the console command https://github.com/adonisjs/assembler/blob/develop/src/helpers.ts#L31 |
Can't we use simple if statement like this to bypass the loader when run via bun? if (process.versions.bun) {
// this code will only run when the file is run with Bun
} |
Nope. Bun should support Node.js code as per their claim. We don't want to patch the AdonisJS codebase to make it work on Bun; they should adapt. |
that makes sense 👍🏻 , meanwhile using the native watcher of the bun seems to do the job well |
There are still some inconsistencies with Bun $ bun bin/server.ts
[12:05:46.878] INFO (74722): started HTTP server on 0.0.0.0:3333
^C⏎
$ bun bin/server.ts
TypeError: undefined is not an object (evaluating 'router.get')
at module code start/routes.ts:13
8| */
9|
10| import HellosController from '#controllers/hellos_controller'
11| import router from '@adonisjs/core/services/router'
12|
❯ 13| router.get('/', async () => 'It works!')
14| router.get('/hello', [HellosController, 'greet'])
15| |
Any progress about it? I mean supporting adonis on Bun? |
MacOS with bun --version 1.1.22 Still have issue
➜ $ bun bin/server.ts --watch
TypeError: undefined is not an object (evaluating 'router.use')
at module code start/kernel.ts:35
30|
31| /**
32| * The router middleware stack runs middleware on all the HTTP
33| * requests with a registered route.
34| */
❯ 35| router.use([() => import('@adonisjs/core/bodyparser_middleware'), () => import('@adonisjs/auth/initialize_auth_middleware')])
36|
37| /**
38| * Named middleware collection must be explicitly assigned to
39| * the routes or the routes group.
40| */ |
on ubuntu with bun, trying to build the adonis project, I get this: bun run build
$ node ace build
1 | (function (entry, fetcher)
^
SyntaxError: Export named 'register' not found in module 'module'.
Bun v1.1.26 (Linux x64)
error: script "build" exited with code 1 |
I am getting the below error when running
|
Is there any update on this? |
There appears to be a regression in Bun ❯ bun bin/server.ts
ResolveMessage: Cannot find module '#start/env' from '/home/romain/workspace/lab/bun-test/bin/server.ts' |
@RomainLanz sorry to ping you, do you know when this is resolved and supported? |
@ildfreelancer, I recommend reaching out to the Bun team for updates, as we are not currently working on making AdonisJS compatible with Bun. The compatibility issues are on Bun's side, not AdonisJS. In the meantime, we suggest using Node.js to try AdonisJS, as the Bun team continues addressing their issues. |
I may have good news. I have changed a bit the default boilerplate of an AdonisJS application to make it work with After @jaredpalmer answer on this topic, I have tried to run the project using Bun, and it works! I will do more testing and do some benchmark! |
After additional testing, I still occasionally encounter the issue mentioned earlier. I suspect this might be related to peer dependency resolution, but I'm not certain. When the server starts, it runs successfully, but Dependency Injection isn't functional yet (similar to the Node.js We'll need to wait for TypeScript to address this issue: microsoft/TypeScript#58101 / microsoft/TypeScript#57533 (comment) Maybe #6326 is related too. |
Here is a small benchmark of our Slim starter-kit with Bun and Node.js. Using: Bun 1.2 Running 40s test @ http://localhost:3333
100 connections with 10 pipelining factor
┌─────────┬───────┬───────┬───────┬───────┬──────────┬─────────┬───────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼───────┼───────┼───────┼───────┼──────────┼─────────┼───────┤
│ Latency │ 13 ms │ 29 ms │ 31 ms │ 32 ms │ 26.31 ms │ 5.82 ms │ 56 ms │
└─────────┴───────┴───────┴───────┴───────┴──────────┴─────────┴───────┘
┌───────────┬─────────┬─────────┬────────┬─────────┬──────────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼────────┼─────────┼──────────┼─────────┼─────────┤
│ Req/Sec │ 35551 │ 35551 │ 37567 │ 37887 │ 37308.81 │ 587 │ 35544 │
├───────────┼─────────┼─────────┼────────┼─────────┼──────────┼─────────┼─────────┤
│ Bytes/Sec │ 5.87 MB │ 5.87 MB │ 6.2 MB │ 6.25 MB │ 6.16 MB │ 96.7 kB │ 5.86 MB │
└───────────┴─────────┴─────────┴────────┴─────────┴──────────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
# of samples: 40
1493k requests in 40.02s, 246 MB read Node.js 22.13 Running 40s test @ http://localhost:3333
100 connections with 10 pipelining factor
┌─────────┬───────┬───────┬───────┬───────┬──────────┬─────────┬────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼───────┼───────┼───────┼───────┼──────────┼─────────┼────────┤
│ Latency │ 12 ms │ 25 ms │ 29 ms │ 30 ms │ 21.69 ms │ 7.57 ms │ 483 ms │
└─────────┴───────┴───────┴───────┴───────┴──────────┴─────────┴────────┘
┌───────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┬─────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Req/Sec │ 43743 │ 43743 │ 45183 │ 45407 │ 45065.6 │ 335.26 │ 43719 │
├───────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│ Bytes/Sec │ 9.27 MB │ 9.27 MB │ 9.58 MB │ 9.63 MB │ 9.55 MB │ 71.3 kB │ 9.27 MB │
└───────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┴─────────┘
Req/Bytes counts sampled once per second.
# of samples: 40
1804k requests in 40.02s, 382 MB read |
Wonder why fewer req/sec 🤔 |
Curious to know the overall memory consumption. The big difference may be there (or not). |
Cool 🔥 |
This is a tracking issue to get bun's node.js compatibility far enough along to support https://adonisjs.com
Intl.ListFormat
Add support forIntl.ListFormat
#808The text was updated successfully, but these errors were encountered: