Home / Companies / Tyk / Blog / Post Details
Content Deep Dive

How to propagate context without cancellation

Blog post from Tyk

Post Details
Company
Tyk
Date Published
Author
Jennifer Craig
Word Count
1,114
Language
English
Hacker News Points
-
Summary

The blog post by Jennifer Craig explores the challenge of propagating context without cancellation in Go, specifically within the Tyk Cloud service used for managing APIs. When onboarding new customers, the company faced issues with their email-sending function due to context cancellation errors, which occurred because the context was tied to the HTTP request lifecycle. This led to premature termination when the context was cancelled after the HTTP handler returned. To address this, the team initially sought external solutions but eventually developed a custom package to detach the context’s cancellation aspect while retaining its values. The problem was later addressed in Go version 1.21, which introduced a standard library feature to propagate context without cancellation. Additionally, a linter was created by Damian Gryski to help developers avoid similar issues in the future. The post also highlights the ease of starting a free trial with Tyk Cloud for API management.