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(notifier): For durable fail(), persist the reason rather than a rejected promise #7011

Merged
merged 3 commits into from
Feb 17, 2023

Conversation

gibson042
Copy link
Member

Fixes #7009

Description

Send the fail reason directly to advanceDurablePublishKit so it can persist the value before wrapping it in a rejected promise to resolve the outstanding tail promise.

Security Considerations

None.

Scaling Considerations

No change.

Documentation Considerations

Not applicable.

Testing Considerations

#6523 should make it possible to update the durable publish kit tests for realistic durability constraints.

Comment on lines 329 to 333
if (targetStatus === 'failed') {
canBeDurable(value) ||
Fail`Cannot accept non-durable fail reason: ${value}`;
} else if (done || valueDurability === 'mandatory') {
canBeDurable(value) || Fail`Cannot accept non-durable value: ${value}`;
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure it's worth keeping a distinct message for fail(nonDurableReason) vs. finish(nonDurableFinalValue) and publish(nonDurableValue). If not, we could simplify this.

Suggested change
if (targetStatus === 'failed') {
canBeDurable(value) ||
Fail`Cannot accept non-durable fail reason: ${value}`;
} else if (done || valueDurability === 'mandatory') {
canBeDurable(value) || Fail`Cannot accept non-durable value: ${value}`;
if (done || valueDurability === 'mandatory') {
canBeDurable(value) || Fail`Cannot accept non-durable value: ${value}`;

Copy link
Member

Choose a reason for hiding this comment

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

The stack trace should show which case it was. The only value I can think of is for a test to be able to verify which failure, but it could do that by exercising both paths. So +1 to the simplification.

Comment on lines 329 to 333
if (targetStatus === 'failed') {
canBeDurable(value) ||
Fail`Cannot accept non-durable fail reason: ${value}`;
} else if (done || valueDurability === 'mandatory') {
canBeDurable(value) || Fail`Cannot accept non-durable value: ${value}`;
Copy link
Member

Choose a reason for hiding this comment

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

The stack trace should show which case it was. The only value I can think of is for a test to be able to verify which failure, but it could do that by exercising both paths. So +1 to the simplification.

* @param {any} value
* @param {any} [rejection]
* @param {DurablePublishKitState["status"]} [targetStatus]
Copy link
Member

Choose a reason for hiding this comment

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

🙌 types

Copy link
Member

Choose a reason for hiding this comment

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

This is a type syntax I have not seen before. What's the difference between

DurablePublishKitState["status"]

vs

DurablePublishKitState.status

or

DurablePublishKitState['status']

?

Copy link
Member

Choose a reason for hiding this comment

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

The two quotes are just stylistic. Our Prettier config is single quotes but it doesn't reach into jsdoc.

The . is reserved for referencing a namespace.

https://www.typescriptlang.org/play?#code/C4TwDgpgBAysCGxoF4oG8BQUoDMD2eAXFAHYCuAtgEYQBOANFlFfLcQM7C0CWJA5gG4MAXwwYAxnhKco7XnwA2EYnEQQA2gHJ8eTQF0oqAExDJ04FAAmeMlSUqESdQCIdzg8dNSZJeBQjsYPDiyrCOEAB0OoZQJhhAA

@gibson042 gibson042 added the automerge:squash Automatically squash merge label Feb 17, 2023
@mergify mergify bot merged commit 0d63b64 into master Feb 17, 2023
@mergify mergify bot deleted the gibson-7009-durablepublishkit-fail branch February 17, 2023 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:squash Automatically squash merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Durable publish kits cannot store failure reasons
3 participants