-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Build attempts connection to dependent services #933
Comments
That's probably because prerendering happens during build: kit/packages/adapter-node/index.cjs Line 26 in 336722a
I can see if you have no prerendered pages how it would be frustrating not to be able to build your site without a connection to prod database though. Perhaps we need a flag to turn off prerendering? Though even that seems like it will trip up a lot of users because it will be trying to connect to your database by default, which may not be desired for many users. I don't see another way of doing this without moving this option outside the realm of file-system routing though (if we had a traditionally configured router we would not need to import the templates to resolve the options). Something similar is happening with the SSR option in #754 (comment) Other options for you to be able to deal with this:
|
Thanks for the reply and suggestions @benmccann I think it would be ideal to go towards that route to turn off prerendering during the build process to avoid having to introduce build concerns within the application code. However, I think that's not a deal breaker and I think I'll personally lean towards introducing those concerns, rather than connection per request to favor performance in my instance. I'm new to Svelte and this project, but if you have thoughts on an improvement that could be made to SvelteKit, then I could try to work through a change and take a swing at it. |
This comment has been minimized.
This comment has been minimized.
reopening since it was auto-closed by a 'maybe closes' comment, but it wasn't confirmed |
I apologize for the delay on vetting this. I have pulled down the latest versions of Thank you! |
Describe the bug
I have a SvelteKit application which connects to a dependent service via a socket using
createConnection
from thenet
module. During the build process to create production assets via thenpm run build
script, it appears to try run my modules, which results in attempting to create the socket to the dependent service.If the service is up, then the socket connection is established and
npm run build
hangs on the open socket, so it does not finish. However, if the service is down, then the socket connection fails, which results in error outputs of the failed connection during the build, and the build finishes.I intentionally desired a socket connection on startup of the application, so I did not need to make a new connection upon each request.
Logs
Listed below are outputs during the build process for when the dependent service is up and also for when it is down. To set some context, the name of the relative service is spidey-db and it runs on port 6425.
Output when dependent service is up. "connected to spidey db" is a debug log statement for reference
Output when dependent service is down.
To Reproduce
This could be reproduced by creating a socket connection within a module, then running build.
This can be replicated with the following folder in the following repository:
https://github.com/kubejm/spidey-db-demo/tree/master/packages/webapp
The socket connection within the repository above can be found here:
https://github.com/kubejm/spidey-db-demo/blob/master/packages/webapp/src/lib/spidey-db/client.ts#L87-L97
The connection is established here:
https://github.com/kubejm/spidey-db-demo/blob/master/packages/webapp/src/lib/spidey-db/index.ts#L6-L9
Expected behavior
Not executing the module within my application code, which attempts to establish a socket connection.
I'm new to Svelte/SvelteKit, so I'm not aware of the build process to produce the production assets. However, ideally it would not need to instantiate/run my assets with the
@sveltejs/adapter-node
to produce them.Information about your SvelteKit Installation:
Diagnostics
Adapter:
@sveltejs/adapter-node
Severity
This is a side project to learn Svelte and SvelteKit, so no urgency on this for me. I am hoping to run this application in Docker, so I'm trying to work towards a production-like state by building the assets and running it within a container.
The text was updated successfully, but these errors were encountered: