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

feat: new timeout writer implementation #1584

Merged
merged 4 commits into from
May 22, 2024
Merged

feat: new timeout writer implementation #1584

merged 4 commits into from
May 22, 2024

Conversation

hf
Copy link
Contributor

@hf hf commented May 17, 2024

#1529 introduced timeout middleware, but it appears from working in the wild it has some race conditions that are not particularly helpful.

This PR rewrites the implementation to get rid of race conditions, at the expense of slightly higher RAM usage. It follows the implementation of http.TimeoutHandler closely.

@hf hf requested a review from a team as a code owner May 17, 2024 12:09
@coveralls
Copy link

coveralls commented May 20, 2024

Pull Request Test Coverage Report for Build 9161432738

Details

  • 60 of 75 (80.0%) changed or added relevant lines in 3 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.04%) to 65.7%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/api/verify.go 10 11 90.91%
internal/api/middleware.go 49 63 77.78%
Files with Coverage Reduction New Missed Lines %
internal/api/verify.go 1 72.55%
internal/api/middleware.go 2 79.85%
Totals Coverage Status
Change from base Build 9124537519: -0.04%
Covered Lines: 8401
Relevant Lines: 12787

💛 - Coveralls

@kangmingtay
Copy link
Member

@hf i've updated the branch with the following changes:

  1. Verify email change shouldn't be calling http.Redirect twice
  2. timeoutMiddleware doesn't have to be a struct method of API since we don't use any of the properties in it
  3. Calling WriteHeader now takes a snapshot of the existing header map. When finallyWrite is called, we'll write the header from the snapshot rather than the header map.

Copy link
Contributor

@J0 J0 left a comment

Choose a reason for hiding this comment

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

Thanks!

@hf hf merged commit 72614a1 into master May 22, 2024
2 checks passed
@hf hf deleted the hf/fix-timeout-writer branch May 22, 2024 09:05
J0 pushed a commit that referenced this pull request May 22, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.152.0](v2.151.0...v2.152.0)
(2024-05-22)


### Features

* new timeout writer implementation
([#1584](#1584))
([72614a1](72614a1))
* remove legacy lookup in users for one_time_tokens (phase II)
([#1569](#1569))
([39ca026](39ca026))
* update chi version
([#1581](#1581))
([c64ae3d](c64ae3d))
* update openapi spec with identity and is_anonymous fields
([#1573](#1573))
([86a79df](86a79df))


### Bug Fixes

* improve logging structure
([#1583](#1583))
([c22fc15](c22fc15))
* sms verify should update is_anonymous field
([#1580](#1580))
([e5f98cb](e5f98cb))
* use api_external_url domain as localname
([#1575](#1575))
([ed2b490](ed2b490))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
supabase#1529 introduced timeout middleware, but it appears from working in the
wild it has some race conditions that are not particularly helpful.

This PR rewrites the implementation to get rid of race conditions, at
the expense of slightly higher RAM usage. It follows the implementation
of `http.TimeoutHandler` closely.

---------

Co-authored-by: Kang Ming <[email protected]>
uxodb pushed a commit to uxodb/auth that referenced this pull request Nov 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.152.0](supabase/auth@v2.151.0...v2.152.0)
(2024-05-22)


### Features

* new timeout writer implementation
([supabase#1584](supabase#1584))
([72614a1](supabase@72614a1))
* remove legacy lookup in users for one_time_tokens (phase II)
([supabase#1569](supabase#1569))
([39ca026](supabase@39ca026))
* update chi version
([supabase#1581](supabase#1581))
([c64ae3d](supabase@c64ae3d))
* update openapi spec with identity and is_anonymous fields
([supabase#1573](supabase#1573))
([86a79df](supabase@86a79df))


### Bug Fixes

* improve logging structure
([supabase#1583](supabase#1583))
([c22fc15](supabase@c22fc15))
* sms verify should update is_anonymous field
([supabase#1580](supabase#1580))
([e5f98cb](supabase@e5f98cb))
* use api_external_url domain as localname
([supabase#1575](supabase#1575))
([ed2b490](supabase@ed2b490))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
supabase#1529 introduced timeout middleware, but it appears from working in the
wild it has some race conditions that are not particularly helpful.

This PR rewrites the implementation to get rid of race conditions, at
the expense of slightly higher RAM usage. It follows the implementation
of `http.TimeoutHandler` closely.

---------

Co-authored-by: Kang Ming <[email protected]>
LashaJini pushed a commit to LashaJini/auth that referenced this pull request Nov 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[2.152.0](supabase/auth@v2.151.0...v2.152.0)
(2024-05-22)


### Features

* new timeout writer implementation
([supabase#1584](supabase#1584))
([72614a1](supabase@72614a1))
* remove legacy lookup in users for one_time_tokens (phase II)
([supabase#1569](supabase#1569))
([39ca026](supabase@39ca026))
* update chi version
([supabase#1581](supabase#1581))
([c64ae3d](supabase@c64ae3d))
* update openapi spec with identity and is_anonymous fields
([supabase#1573](supabase#1573))
([86a79df](supabase@86a79df))


### Bug Fixes

* improve logging structure
([supabase#1583](supabase#1583))
([c22fc15](supabase@c22fc15))
* sms verify should update is_anonymous field
([supabase#1580](supabase#1580))
([e5f98cb](supabase@e5f98cb))
* use api_external_url domain as localname
([supabase#1575](supabase#1575))
([ed2b490](supabase@ed2b490))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

4 participants