Skip to content
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 for multiple dbos app files in NextJs App #700

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

manojdbos
Copy link
Contributor

No description provided.

@@ -45,7 +45,8 @@ class dbosWorkflowClass {
// This code needs to execute at least once to launch the DBOS runtime
// Do not delete this code
if (process.env.NEXT_PHASE !== "phase-production-build") {
await DBOS.launch();
await DBOS.register(dbosWorkflowClass);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there no longer any need for DBOS.launch()?

Copy link
Contributor Author

@manojdbos manojdbos Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in NextJs. register calls launch.

But we do need to run the launch method once

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is having classes registered after launch. This is guaranteed to not be 100% working at the moment...

@@ -147,9 +147,27 @@ export class DBOS {
set(conf, key, newValue);
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
static async register(cls: any) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do this and launch relate? Does launch do things that this doesn't? When do you need both or just one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Register registers one class.

Launch intializes various things in the runtime like http, loggers, db connections etc. It does have some registration code that needs to be refactored out imho.

Launch needs to be called only once.

Register needs to be called once per file. Register calls launch because someone has to call launch but launch wll run only once

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! And is it okay if launch runs before all registers are done?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Because we explicitly register again

@kraftp kraftp requested a review from chuck-dbos January 9, 2025 19:36
@chuck-dbos
Copy link
Collaborator

I want time to finish exploring a different approach.

@chuck-dbos
Copy link
Collaborator

"A different approach" == "the one on the chuck/next branch".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants