-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Exporting Elysia from file causes server to run twice #550
Comments
Why are you exporting it? If you need only type, you can do |
I'm exporting it so I can pass it to import app from './';
import {treaty} from '@elysiajs/eden';
const api = treaty(app); |
It's bun behaviour |
Close as not going to fix as it's Bun behavior, and changing this behavior would introduce large breaking change. |
I put up a small PR to update the docs around this, which I hope will help those who are new to Elysia. I hope you'll consider adding it. elysiajs/documentation#384 |
What version of Elysia.JS is running?
1.0.0
What platform is your computer?
Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Create a basic Elysia server like this:
Then run the server via
bun index.ts
.What is the expected behavior?
Server should run with no errors.
What do you see instead?
Server crashes with:
The problem seems to be that doing
export default app
in Elysia 1.0.0 causes a separatelisten
call to be executed.Removing
export default app
makes the issue go away, but this means you can't import the file for the purpose of unit testing as shown here.Removing
listen(8080)
also makes the issue go away, but causesapp.server
not to be defined, so the console message prints:API is running at undefined:undefined
instead.I can also remove
export default app
and changeconst app = ...
toexport const app = ...
to fix this, and I suppose this is what you recommend to do, but this behavior was not expected (or documented) so I thought I'd log it.Additional information
No response
The text was updated successfully, but these errors were encountered: