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

Try to solve some timeout issue #586

Closed
wants to merge 6 commits into from
Closed

Conversation

harryzcy
Copy link

@harryzcy harryzcy commented Mar 12, 2024

Resolves #ISSUE_NUMBER

Split the test handle 401 in first 5 seconds to two separate tests.

Try to fix errors in PR #580


Before the change?

After the change?

Pull request checklist

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@harryzcy
Copy link
Author

harryzcy commented Mar 12, 2024

@wolfy1339 It seems the test only timeouts when it's always a 401 response. If it's eventually 200, the test will pass

@harryzcy
Copy link
Author

harryzcy commented Mar 12, 2024

Looks like timeSinceTokenCreationInMs is always 0. So it always does the retries. Maybe Date is locked?

// src/hook.ts
const timeSinceTokenCreationInMs = +new Date() - +new Date(createdAt);

@wolfy1339
Copy link
Member

Date is being overridden by @sinonjs/fake-timers, which is intended. However it shouldn't stay at 0, it should increment by the time argument passed to clock.tickAsync()

@harryzcy
Copy link
Author

Date is being overridden by @sinonjs/fake-timers, which is intended. However it shouldn't stay at 0, it should increment by the time argument passed to clock.tickAsync()

I don't quite know how createdAt will be non-zero. Do you have any idea why?

@wolfy1339
Copy link
Member

in this case, createdAt should be zero, that is the intended behaviour. The mock Date is set to 0, and we increment the clock after creating the token

@harryzcy
Copy link
Author

in this case, createdAt should be zero, that is the intended behaviour. The mock Date is set to 0, and we increment the clock after creating the token

Looking at the log hooks.ts:123 date: 6000, createdAt:6000, timeSince: 0, >=5s: false. The start time be 6000 in the test auth.hook(): fail with 401 after 5 seconds. So we never reach the points that Date difference exceeds 5 seconds.

@wolfy1339
Copy link
Member

@gr2m Might know more

@wolfy1339 wolfy1339 deleted the branch octokit:beta April 30, 2024 17:05
@wolfy1339 wolfy1339 closed this Apr 30, 2024
@harryzcy harryzcy deleted the zcy/beta branch April 30, 2024 22:34
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