Skip to content

🐛 oneshot continuation should throw the same error consistently#9

Merged
cowboyd merged 1 commit intov0from
one-shot-errors
Mar 10, 2023
Merged

🐛 oneshot continuation should throw the same error consistently#9
cowboyd merged 1 commit intov0from
one-shot-errors

Conversation

@cowboyd
Copy link
Copy Markdown
Member

@cowboyd cowboyd commented Mar 9, 2023

Motivation

It turns out that there was a bug with the oneshot() logic, where if an error was raised, then the next time, the continuation would successfully return undefined. This was not being caught because the test case was broken (It did not check that the boom() continuation failed, only that if it did, the message of the exception was the same,

Approach

This fixes the test, and then in the event of a failure, saves the error (much in the same way that the result is saved) and then subsequent calls to this function will raise the exact same exception.

Alternate Designs

We could leave it as-is, because it doesn't seem to be causing any problems, but it seems like the symmetric case of resolution and rejection should be handled the same. If the continuation caches the result, then it should also cache the exception.

It turns out that there was a bug with the `oneshot()` logic, where if
an error was raised, then the next time, the continuation would
successfully return undefined. This was not being caught because the
test case was broken (It did not check that the `boom()` continuation
failed, only that if it did, the message of the exception was the
same,

This fixes the test, and then in the event of a failure, saves the
error (much in the same way that the result is saved) and then
subsequent calls to this function will raise the exact same exception.

We could leave it as-is, because it doesn't seem to be causing any
problems, but it seems like the symmetric case of resolution and
rejection should be handled the same. If the continuation caches the
result, then it should also cache the exception.
Copy link
Copy Markdown
Collaborator

@neurosnap neurosnap left a comment

Choose a reason for hiding this comment

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

We could leave it as-is, because it doesn't seem to be causing any problems, but it seems like the symmetric case of resolution and rejection should be handled the same. If the continuation caches the result, then it should also cache the exception.

I agree with this and there aren't any breaking changes, right? Seems like a pretty straight-forward improvement!

Comment thread mod.ts
Comment thread t/continuation.test.ts
@cowboyd cowboyd merged commit 94e748f into v0 Mar 10, 2023
@cowboyd cowboyd deleted the one-shot-errors branch March 10, 2023 14:47
@cowboyd cowboyd mentioned this pull request Mar 20, 2023
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