Skip to content

Commit 3a98bbb

Browse files
committed
fixup! fix tests
1 parent 86d66b1 commit 3a98bbb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

codersdk/toolsdk/toolsdk.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ func WithCleanContext(h GenericHandlerFunc) GenericHandlerFunc {
156156
return func(parent context.Context, tb Deps, args json.RawMessage) (ret json.RawMessage, err error) {
157157
child, childCancel := context.WithCancel(context.Background())
158158
defer childCancel()
159+
// Ensure that the child context has the same deadline as the parent
160+
// context.
161+
if deadline, ok := parent.Deadline(); ok {
162+
deadlineCtx, deadlineCancel := context.WithDeadline(child, deadline)
163+
defer deadlineCancel()
164+
child = deadlineCtx
165+
}
159166
// Ensure that cancellation propagates from the parent context to the child context.
160167
go func() {
161168
select {
@@ -165,13 +172,6 @@ func WithCleanContext(h GenericHandlerFunc) GenericHandlerFunc {
165172
childCancel()
166173
}
167174
}()
168-
// Also ensure that the child context has the same deadline as the parent
169-
// context.
170-
if deadline, ok := parent.Deadline(); ok {
171-
deadlineCtx, deadlineCancel := context.WithDeadline(child, deadline)
172-
defer deadlineCancel()
173-
child = deadlineCtx
174-
}
175175
return h(child, tb, args)
176176
}
177177
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy