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

Fix Debug Mode Output Check #223

Merged
merged 5 commits into from
Dec 15, 2023
Merged

Fix Debug Mode Output Check #223

merged 5 commits into from
Dec 15, 2023

Conversation

qianl15
Copy link
Member

@qianl15 qianl15 commented Dec 15, 2023

This PR solves a minor issue for the debug mode: If a function returns nothing, we record null in the database (there's no good way to serialize undefined to a valid JSON string). So when we get the recorded output, we would get null instead of undefined. Therefore, the debugger would incorrectly print out an error message when it compares undefined to null when the function returns nothing.

This PR updates the debug mode code to handle the undefined return value.

@@ -113,10 +113,17 @@ export class WorkflowContextDebug extends DBOSContextImpl implements WorkflowCon

const result = await this.#dbosExec.userDatabase.transaction(wrappedTransaction, txnInfo.config);

// If returned nothing and the recorded value is also null/undefined, we just return it
if (result === undefined && !check!.output) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what is the ! before check mean?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Never mind, it's not. the use of ! for both not and "ignore maybe null" threw me

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe explicitly compare check!.output to false to make this clearer?

@qianl15 qianl15 merged commit c6f1bbf into main Dec 15, 2023
2 checks passed
@qianl15 qianl15 deleted the qian/debug-mode-return branch December 15, 2023 00:25
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.

2 participants