Skip to content

Conversation

PhakornKiong
Copy link
Contributor

Resolves #85

dbos/workflow.go Outdated
Comment on lines 199 to 200
case <-h.dbosContext.Done():
return *new(R), h.dbosContext.Err()
Copy link
Contributor Author

@PhakornKiong PhakornKiong Oct 4, 2025

Choose a reason for hiding this comment

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

@maxdml I'm unable to get to this code path, so not sure if we really need it.

Tried shutting down DBOS server, but it get DB error from h.outcomeChan instead.

Let me know your thoughts

Copy link
Collaborator

Choose a reason for hiding this comment

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

For this path to kick in, you need to manually Launch and Shutdown the DBOSContext in a test. The sequence would be:

  • Launch
  • Run blocking workflow (so that the function doesn't return and its result never reaches outcomeChan)
  • GetResult with no timeout
  • Shutdown DBOSContext
  • GetResult should result the error (which should be a context.Context DeadlineExceeded error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this to work, the workflow must signal that it started, which you can achieve by using the test utilities "event" API. See an example here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For this case, should it be context.Canceled instead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You mean for a test exercising case <-h.dbosContext.Done(): ? You're right, it depends on how the context is cancelled (manually or through a deadline)

Copy link
Collaborator

@maxdml maxdml left a comment

Choose a reason for hiding this comment

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

Thanks @PhakornKiong . Left a few comments. Let me know if you have more questions!

dbos/workflow.go Outdated
Comment on lines 199 to 200
case <-h.dbosContext.Done():
return *new(R), h.dbosContext.Err()
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this path to kick in, you need to manually Launch and Shutdown the DBOSContext in a test. The sequence would be:

  • Launch
  • Run blocking workflow (so that the function doesn't return and its result never reaches outcomeChan)
  • GetResult with no timeout
  • Shutdown DBOSContext
  • GetResult should result the error (which should be a context.Context DeadlineExceeded error)
dbos/workflow.go Outdated
Comment on lines 199 to 200
case <-h.dbosContext.Done():
return *new(R), h.dbosContext.Err()
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this to work, the workflow must signal that it started, which you can achieve by using the test utilities "event" API. See an example here.

@PhakornKiong PhakornKiong requested a review from maxdml October 7, 2025 07:37
@PhakornKiong PhakornKiong force-pushed the cancellable-get-results branch from 8653f7d to 523e6af Compare October 7, 2025 20:04
@maxdml maxdml force-pushed the cancellable-get-results branch from 523e6af to 57a0a17 Compare October 8, 2025 01:47
@PhakornKiong
Copy link
Contributor Author

@maxdml Noticed that there are test like TestEnqueue/EnqueueWithTimeout that fails, is it a flaky test?

I tired running on local as well as on my forked repo and it went fine.

Let me know if there are any other changes that i should make

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants