denoland / fresh

The next-gen web framework.
https://fresh.deno.dev
MIT License
12.17k stars 623 forks source link

`kv.listenQueue` prevents build mode from working #2240

Open marvinhagemeister opened 8 months ago

marvinhagemeister commented 8 months ago

The kv.listenQueue() function prevents the process from exiting because it waits for messages forever. This breaks the build command.

We should probably add something similar to IS_BROWSER like IS_BUILD_MODE or something so that users can exclude long running stuff from being executed during build.

Another approach would be to avoid importing user code during build. Off the top of my head I think we only import user code during build for the manifest generation. Maybe we should replace that with AST-based logic. That way user's don't need to add conditionals or anything to their code.

mcgear commented 8 months ago

I was just trying to figure out a workaround for this, until we get something going in the framework. Any thoughts?

mcgear commented 8 months ago

For now, i have settled on managing a second dev.build.ts file that just doesn't import my handlers, and that seems to be working.

marvinhagemeister commented 8 months ago

A workaround is to check if Fresh is running in build mode and then skipping the logic. Something like:

if (!Deno.args.includes("build")) {
  somethingThatShouldNotRunDuringBuild();
}
mohankoppuravuri commented 5 hours ago

Fresh provides fresh.config.ts file. In side this file you can pass custom configurations. It take onListen callback which triggers when server starts listening.

Connect to remote systems here