-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(kv): throw error if already closed #21459
Conversation
|
||
queueTest("throw error if already closed", async (db) => { | ||
db.close(); | ||
await assertThrows( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assertRejects
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, I used assertRejects
only, but it got failed 😅.
I don't know, test cases are running fine on my system but failed here.
await assertRejects( | ||
async () => { | ||
await db.listenQueue(() => { | ||
resolve(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolve is not needed, since you don't destructure promise
from Promise.withResolvers()
it's useless in this context. I think you can give it an empty callback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First, I did the same, but it failed.
Did it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accepted too quickly, the test is failing
cli/tests/unit/kv_queue_test.ts
Outdated
db.close(); | ||
await assertRejects( | ||
async () => { | ||
await db.listenQueue(() => {}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
normally listenQueue
is called without await
. can we test here that it throws without await?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Locally, it's failing without await
. listenQueue
return promise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I handled using try-catch :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My test cases are passing, but something else is failing @igorzi can you please check?
cli/tests/unit/kv_queue_test.ts
Outdated
await db.listenQueue(() => {}); | ||
} catch (e) { | ||
assertEquals(e.message, "already closed"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it doesn't throw? Right now the test will pass if it doesn't throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch :).
Added assertFalse(false)
after line 9 so if doesn't throw it will fail.
Description
If KV is closed and tries to listen queue should throw an error.
Issue
.listenQueue
should throw once.close
is called #20991