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

Use builtin library and add test to verify that delay is actually delaying #613

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

phillipperalez
Copy link
Collaborator

Previous Promise didn't appear to actually be applying delays

@phillipperalez phillipperalez requested a review from a team as a code owner July 20, 2024 19:48
@@ -25,6 +25,6 @@ export declare class GoogleSheetsAction extends GoogleDriveAction {
retriableFileList(drive: Drive, options: any, attempt: number, webhookId: string): Promise<any>;
flush(buffer: sheets_v4.Schema$BatchUpdateSpreadsheetRequest, sheet: Sheet, spreadsheetId: string, webhookId: string): Promise<import("gaxios").GaxiosResponse<sheets_v4.Schema$BatchUpdateSpreadsheetResponse>>;
flushRetry(buffer: sheets_v4.Schema$BatchUpdateSpreadsheetRequest, sheet: Sheet, spreadsheetId: string, webhookId: string): Promise<import("gaxios").GaxiosResponse<sheets_v4.Schema$BatchUpdateSpreadsheetResponse>>;
protected delay(time: number): Promise<void>;
delay(time: number): Promise<void>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What effect are you achieving here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it doesn't particularly matter and then I can actually test the function

@@ -538,6 +538,15 @@ describe(`${action.constructor.name} unit tests`, () => {
})
})

describe("delay", () => {
it("will block on await delay", async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you provide more detail for why this is necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the previous implementation, although it looked correct, was not actually delaying retries. I am seeing another area which I missed so I will upload another change to this as well

describe("delay", () => {
it("will block on await delay", async () => {
const start = Date.now()
await action.delay(100)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are the units here?

const start = Date.now()
await action.delay(100)
const end = Date.now()
chai.expect(end - start).to.be.greaterThanOrEqual(10)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are the units here?

await new Promise<void>((resolve) => {
setTimeout(resolve, time)
})
async delay(time: number) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What are the units here?

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