-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
π [Bug]: v3 ctx.Context() is cancelled upon creation #3186
Comments
Thanks for opening your first issue here! π Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
@gistart I believe you want to use The @ReneWerner87 We should rename this functions, it's confusing for Golang devs that are used to using |
@gaby oh wow, I didn't realize that I shouldn't use // Context returns *fasthttp.RequestCtx that carries a deadline
// a cancellation signal, and other values across API boundaries.
Context() *fasthttp.RequestCtx
// UserContext returns a context implementation that was set by
// user earlier or returns a non-nil, empty context,if it was not set earlier.
UserContext() context.Context I thought it's a good idea to use fiber's context for db queries bcs it might implement all the important logic around user disconnects, request timeouts, graceful shutdowns, etc. Does UserContext have any of these? If not, could you please share a tip on how to implement it myself? |
which name would be better ?
|
Probably |
I will do a PR for this today (renaming). @gistart I will get back to you on your questions once I read the code a bit more. But I believe that With my PR I will rename:
|
* Rename UserContext() to Context(). Rename Context() to RequestCtx() * feat: add requestID in UserContext * Update Ctxt docs and What's new * Remove extra blank lines * β»οΈ Refactor: merge issue #3186 * π₯ Feature: improve FromContext func and test * π Doc: improve requestid middleware * β»οΈ Refactor: Rename interface to any * fix: Modify structure sorting to reduce memory usage --------- Co-authored-by: Juan Calderon-Perez <jgcalderonperez@protonmail.com> Co-authored-by: Juan Calderon-Perez <835733+gaby@users.noreply.github.com>
Bug Description
Running app normally w/ Listen -- context is fine, so I can use it for my db queries.
Running a test on the same app -- and context is cancelled upon creation
How to Reproduce
See code snippet below
Expected Behavior
Context in both prod and test should be initialized as not Done, w/o any errors.
Fiber Version
v3.0.0-beta.3
Code Snippet (optional)
Checklist:
The text was updated successfully, but these errors were encountered: