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(executor): added error when no proposals are received #607

Merged
merged 23 commits into from
Oct 19, 2023

Conversation

mgordel
Copy link
Contributor

@mgordel mgordel commented Oct 4, 2023

JST-462: Added startupTimeout (default 30sec) as TaskExecutor option, after which if there is no at least one proposal we will get an appropriate error

JST-462: Added startupTimeout (default 30sec) as TaskExecutor option,
after which if there is no at least one proposal we will get an appropriate error
@@ -54,6 +54,8 @@ export type ExecutorOptions = {
* For more details see {@link JobStorage}. Defaults to a simple in-memory storage.
*/
jobStorage?: JobStorage;
/** Timeout for waiting for at least one offer from the market */
Copy link
Contributor

Choose a reason for hiding this comment

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

Please provide a more user friendly description in the second line, explaining why the user should care and what they can do with this setting, what will happen when the timeout is reached. Documenting it here is far more important than writing the article in the docs :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right, I'll add a better description

@@ -385,11 +390,29 @@ export class TaskExecutor {
timeout: options?.timeout ?? this.options.taskTimeout,
});
this.taskQueue.addToEnd(task as Task<unknown, unknown>);
if (!this.startupTimeoutError && !this.startupTimeoutId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have few issues with this, we can talk about this f2f:

  • This way of communicating the error with the timeout isn't easy for the user to handle, we should work on that
  • Since this is implemented as part of executeTask, this timeout will be started and counted for each scheduled task. I do see a concurrency problem here, given all the tasks are executed on the same TaskExecutor instance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this timeout will only start once, unless this.startupTimeoutId exists yet, so there shouldn't be a problem with concurrency, I think, but let's talk about it..

@@ -27,6 +27,7 @@ export interface DemandOptions {
offerFetchingInterval?: number;
proposalTimeout?: number;
eventTarget?: EventTarget;
startupTimeout?: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

This field should be documented as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is unnecessary, left by mistake, i will delete it

@@ -28,6 +27,12 @@ export class MarketService {
private logger?: Logger;
private taskPackage?: Package;
private maxResubscribeRetries = 5;
private proposalsCount = {
initial: 0,
filtered: 0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Filtered means accepted or rejected? The naming is confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

filtered is not used, it was left by mistake

@mgordel mgordel requested a review from grisha87 October 6, 2023 11:13
Copy link
Contributor

@grisha87 grisha87 left a comment

Choose a reason for hiding this comment

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

As discussed during the call, please move the timeout tracking logic out of the "task execution phase", back to the initialisation.

@mgordel mgordel requested a review from grisha87 October 17, 2023 10:50
@mgordel mgordel merged commit 17d90fa into beta Oct 19, 2023
11 checks passed
@mgordel mgordel deleted the bugfix/JST-462/no-proposal-warning branch October 19, 2023 10:38
@github-actions
Copy link

🎉 This PR is included in version 0.12.0-beta.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

2 participants